Skip to content

Commit 4e36065

Browse files
committed
update docs
1 parent 6b3a856 commit 4e36065

File tree

1 file changed

+155
-5
lines changed

1 file changed

+155
-5
lines changed

docs/references/Services.md

Lines changed: 155 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,166 @@ $templateSlug = 'blog-template';
104104
$template = inspirecms_content()->getTemplateFor($content, $templateSlug);
105105
```
106106

107-
### Customizing the Content Service
108-
You can customize the Content Service by binding your own implementation in your application's ServiceProvider. This allows you to extend or completely replace the default content management functionality with your own business logic.
107+
---
109108

110-
In your ServiceProvider's `boot` method, use Laravel's service container to register your custom implementation:
111-
You can customize the Content Service by binding your own implementation:
109+
## Asset Service
110+
111+
The Asset Service allows you to manage media assets such as images and files.
112+
113+
### Accessing the Service
114+
```php
115+
$service = app(\SolutionForest\InspireCms\Services\AssetServiceInterface::class);
116+
// or
117+
$service = inspirecms_asset();
118+
```
119+
120+
### Example Usage
121+
122+
#### Find Media Assets
123+
Retrieve multiple media assets by their keys:
124+
```php
125+
$mediaAssets = inspirecms_asset()->findByKeys([
126+
'550e8400-e29b-41d4-a716-446655440000',
127+
'550e8400-e29b-41d4-a716-446655440001'
128+
]);
129+
```
130+
131+
---
132+
133+
## Import Data Service
134+
135+
The Import Data Service allows you to programmatically define and import content, templates, and navigation.
136+
137+
### Accessing the Service
138+
```php
139+
$service = app(\SolutionForest\InspireCms\Services\ImportDataServiceInterface::class);
140+
```
141+
142+
### Example Usage
143+
```php
144+
use SolutionForest\InspireCms\ImportData\Entities;
145+
146+
$service = app(\SolutionForest\InspireCms\Services\ImportDataServiceInterface::class);
147+
148+
$service->addDocumentType('home', new Entities\DocumentType(
149+
slug: 'home',
150+
showAsTable: false,
151+
showAtRoot: true,
152+
category: 'web',
153+
icon: 'heroicon-o-home',
154+
fieldGroups: ['hero'],
155+
templates: ['home'],
156+
defaultTemplate: 'home',
157+
));
158+
159+
$service->addFieldGroup('hero', new Entities\FieldGroup(
160+
slug: 'hero',
161+
fields: [
162+
new Entities\Field(slug: 'title', type: 'text', config: ['translatable' => true]),
163+
new Entities\Field(slug: 'image_slider', type: 'mediaPicker', config: ['types' => ['image']]),
164+
],
165+
));
166+
167+
$service->addTemplate('home', '<p>Sample content</p>');
168+
$service->addTemplate('home2');
169+
$service->addTemplate('home3', \SolutionForest\InspireCms\Helpers\TemplateHelper::retrieveDefaultThemeContent());
170+
$service$service->addTemplate('home2');
171+
$service->addTemplate('home3', \SolutionForest\InspireCms\Helpers\TemplateHelper::retrieveDefaultThemeContent());
172+
->addCon$service->addTemplate('home2');
173+
$service->addTemplate('home3', \SolutionForest\InspireCms\Helpers\TemplateHelper::retrieveDefaultThemeContent());
174+
tent('home', null, new Entities\Content(
175+
slug: 'home',
176+
title: ['en' => 'Home'],
177+
documentType: 'home',
178+
isDefault: true,
179+
properties: [
180+
'hero' => [
181+
'title' => ['en' => 'Hello World'],
182+
'image_slider' => [],
183+
],
184+
],
185+
publishState: 'publish'
186+
));
187+
$service->addNavigation(new Entities\Navigation(
188+
category: 'main',
189+
type: 'content',
190+
title: ['en' => 'Home'],
191+
contentSlugPath: 'home',
192+
));
193+
$service->addNavigation(new Entities\Navigation(
194+
category: 'main',
195+
type: 'content',
196+
title: ['en' => 'About'],
197+
contentSlugPath: 'home/about',
198+
));
199+
$servi$service->addNavigation(new Entities\Navigation(
200+
category: 'main',
201+
type: 'content',
202+
title: ['en' => 'Home'],
203+
contentSlugPath: 'home',
204+
));
205+
$service->addNavigation(new Entities\Navigation(
206+
category: 'main',
207+
type: 'content',
208+
title: ['en' => 'About'],
209+
contentSlugPath: 'home/about',
210+
));
211+
212+
$service->run();
213+
```
214+
215+
---
216+
217+
## Import Service
218+
219+
The Import Service allows you to execute import operations for predefined records.
220+
221+
### Accessing the Service
222+
```php
223+
$service = app(\SolutionForest\InspireCms\Services\ImportServiceInterface::class);
224+
```
225+
226+
### Example Usage
227+
```php
228+
use SolutionForest\InspireCms\Models\Contracts\Import;
229+
230+
$record = app(Import::class)::find(1);
231+
app(\SolutionForest\InspireCms\Services\ImportServiceInterface::class)->execute($record);
232+
```
233+
234+
---
235+
236+
## Export Service
237+
238+
The Export Service allows you to execute export operations for predefined records.
239+
240+
### Accessing the Service
241+
```php
242+
$service = app(\SolutionForest\InspireCms\Services\ExportServiceInterface::class);
243+
```
244+
245+
### Example Usage
246+
```php
247+
use SolutionForest\InspireCms\Models\Contracts\Export;
248+
249+
$record = app(Export::class)::find(1);
250+
app(\SolutionForest\InspireCms\Services\ExportServiceInterface::class)->execute($record);
251+
```
252+
253+
---
254+
255+
## Customizing Services
256+
257+
You can customize any service by binding your own implementation in your ServiceProvider's `boot` method:
112258
```php
259+
use SolutionForest\InspireCms\Services\AssetServiceInterface;
113260
use SolutionForest\InspireCms\Services\ContentServiceInterface;
114261

115262
public function boot()
116263
{
117-
$this->app->singleton(ContentServiceInterface::class, fn () => new YourService());
264+
// Customizing Content Service
265+
$this->app->singleton(ContentServiceInterface::class, fn () => new YourContentService());
266+
// Customizing Asset Service
267+
$this->app->singleton(AssetServiceInterface::class, fn () => new YourAssetService());
118268
}
119269
```

0 commit comments

Comments
 (0)