Skip to content

Commit 3f920d1

Browse files
committed
include_file VS include_code
1 parent 1e32544 commit 3f920d1

3 files changed

Lines changed: 111 additions & 0 deletions

File tree

docs/administration/recent_activity/recent_activity.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ It uses the default `admin` user that has a [permission](#permission-and-securit
8585
```php hl_lines="34-38"
8686
[[= include_file('code_samples/recent_activity/src/Command/MonitorRecentContentCreationCommand.php') =]]
8787
```
88+
```php hl_lines="34-38"
89+
[[= include_code('code_samples/recent_activity/src/Command/MonitorRecentContentCreationCommand.php') =]]
90+
```
8891

8992
```console
9093
% php bin/console app:monitor-content-creation
@@ -145,6 +148,9 @@ This event has the information needed by a log entry (see details after the exam
145148
```php
146149
[[= include_file('code_samples/recent_activity/src/EventSubscriber/MyFeatureEventSubscriber.php') =]]
147150
```
151+
```php
152+
[[= include_code('code_samples/recent_activity/src/EventSubscriber/MyFeatureEventSubscriber.php') =]]
153+
```
148154

149155
`ActivityLogService::build()` function returns an `Ibexa\Contracts\ActivityLog\Values\CreateActivityLogStruct` which can then be passed to `ActivityLogService::save`.
150156

@@ -192,6 +198,9 @@ In the following example, several actions are logged into one context group, eve
192198
``` php
193199
[[= include_file('code_samples/recent_activity/src/Command/ActivityLogContextTestCommand.php', 46, 66, remove_indent=True) =]]
194200
```
201+
``` php
202+
[[= include_code('code_samples/recent_activity/src/Command/ActivityLogContextTestCommand.php', 47, 66, remove_indent=True) =]]
203+
```
195204

196205
Context groups can't be nested.
197206
If a new context is prepared when a context is already grouping log entries, this new context is ignored.
@@ -229,12 +238,18 @@ It can be used during development as a fallback for classes that aren't mapped y
229238
``` twig
230239
[[= include_file('code_samples/recent_activity/templates/themes/admin/activity_log/ui/default.html.twig') =]]
231240
```
241+
``` twig
242+
[[= include_code('code_samples/recent_activity/templates/themes/admin/activity_log/ui/default.html.twig') =]]
243+
```
232244

233245
Here is an example of a `ClassNameMapperInterface` associating the class `App\MyFeature\MyFeature` with the identifier `my_feature`:
234246

235247
``` php
236248
[[= include_file('code_samples/recent_activity/src/ActivityLog/ClassNameMapper/MyFeatureNameMapper.php') =]]
237249
```
250+
``` php
251+
[[= include_code('code_samples/recent_activity/src/ActivityLog/ClassNameMapper/MyFeatureNameMapper.php') =]]
252+
```
238253

239254
This mapper also provides a translation for the class name in the **Filters** menu.
240255
This translation can be extracted with `php bin/console jms:translation:extract en --domain=ibexa_activity_log --dir=src --output-dir=translations`.
@@ -244,12 +259,18 @@ To be taken into account, this mapper must be registered as a service:
244259
``` yaml
245260
[[= include_file('code_samples/recent_activity/config/append_to_services.yaml') =]]
246261
```
262+
``` yaml
263+
[[= include_code('code_samples/recent_activity/config/append_to_services.yaml') =]]
264+
```
247265

248266
Here is an example of a `PostActivityListLoadEvent` subscriber which loads the related object when it's an `App\MyFeature\MyFeature`, and attaches it to the log entry:
249267

250268
``` php
251269
[[= include_file('code_samples/recent_activity/src/EventSubscriber/MyFeaturePostActivityListLoadEventSubscriber.php') =]]
252270
```
271+
``` php
272+
[[= include_code('code_samples/recent_activity/src/EventSubscriber/MyFeaturePostActivityListLoadEventSubscriber.php') =]]
273+
```
253274

254275
The following template is made to display the object of `App\MyFeature\MyFeature` (now identified as `my_feature`) when the action is `simulate`,
255276
so, it's named in `templates/themes/admin/activity_log/ui/my_feature/simulate.html.twig`.
@@ -258,6 +279,9 @@ Thanks to the previous subscriber, the related object is available at display ti
258279
``` twig
259280
[[= include_file('code_samples/recent_activity/templates/themes/admin/activity_log/ui/my_feature/simulate.html.twig') =]]
260281
```
282+
``` twig
283+
[[= include_code('code_samples/recent_activity/templates/themes/admin/activity_log/ui/my_feature/simulate.html.twig') =]]
284+
```
261285

262286
## REST API
263287

docs/api/rest_api/rest_api_usage/rest_requests.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,18 @@ This script:
171171
``` php
172172
[[= include_file('code_samples/api/rest_api/create_image.xml.php', 0, None, ' ') =]]
173173
```
174+
``` php
175+
[[= include_code('code_samples/api/rest_api/create_image.xml.php', 1, None, 1) =]]
176+
```
174177

175178
=== "JSON"
176179

177180
``` php
178181
[[= include_file('code_samples/api/rest_api/create_image.json.php', 0, None, ' ') =]]
179182
```
183+
``` php
184+
[[= include_code('code_samples/api/rest_api/create_image.json.php', indent_level=1) =]]
185+
```
180186

181187
### Search (`/views`)
182188

docs/search/search_api.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ The following command takes the content type identifier as an argument and lists
3434
[[= include_file('code_samples/api/public_php_api/src/Command/FindContentCommand.php', 32, 48) =]]
3535
[[= include_file('code_samples/api/public_php_api/src/Command/FindContentCommand.php', 48, 49) =]]
3636
```
37+
``` php hl_lines="14 16"
38+
// ...
39+
[[= include_code('code_samples/api/public_php_api/src/Command/FindContentCommand.php', 5, 7) =]]
40+
// ...
41+
[[= include_code('code_samples/api/public_php_api/src/Command/FindContentCommand.php', 18, 19) =]]
42+
// ...
43+
[[= include_code('code_samples/api/public_php_api/src/Command/FindContentCommand.php', 33, 48) =]]
44+
[[= include_code('code_samples/api/public_php_api/src/Command/FindContentCommand.php', 49, 49) =]]
45+
```
3746

3847
[`SearchService::findContentInfo`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-SearchService.html#method_findContentInfo) (line 16)
3948
retrieves [`ContentInfo`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Persistence-Content-ContentInfo.html) objects of the found content items.
@@ -124,6 +133,14 @@ For example, the following command lists all content items under the specified p
124133
// ...
125134
[[= include_file('code_samples/api/public_php_api/src/Command/FilterCommand.php', 19, 21) =]][[= include_file('code_samples/api/public_php_api/src/Command/FilterCommand.php', 33, 53) =]]
126135
```
136+
``` php hl_lines="15-18"
137+
// ...
138+
[[= include_code('code_samples/api/public_php_api/src/Command/FilterCommand.php', 5, 9) =]]
139+
140+
// ...
141+
[[= include_code('code_samples/api/public_php_api/src/Command/FilterCommand.php', 20, 21) =]]
142+
[[= include_code('code_samples/api/public_php_api/src/Command/FilterCommand.php', 34, 53) =]]
143+
```
127144

128145
The same Filter can be applied to find locations instead of content items, for example:
129146

@@ -133,6 +150,14 @@ The same Filter can be applied to find locations instead of content items, for e
133150
[[= include_file('code_samples/api/public_php_api/src/Command/FilterCommand.php', 19, 21) =]]// ...
134151
[[= include_file('code_samples/api/public_php_api/src/Command/FilterLocationCommand.php', 33, 53) =]]
135152
```
153+
``` php hl_lines="20"
154+
// ...
155+
[[= include_code('code_samples/api/public_php_api/src/Command/FilterLocationCommand.php', 5, 9) =]]
156+
157+
[[= include_code('code_samples/api/public_php_api/src/Command/FilterCommand.php', 20, 21) =]]
158+
// ...
159+
[[= include_code('code_samples/api/public_php_api/src/Command/FilterLocationCommand.php', 34, 53) =]]
160+
```
136161

137162
!!! caution
138163

@@ -186,6 +211,12 @@ For example, in the code below, `locationId` is provided to list all children of
186211
[[= include_file('code_samples/api/public_php_api/src/Controller/CustomController.php', 4, 12) =]] // ...
187212
[[= include_file('code_samples/api/public_php_api/src/Controller/CustomController.php', 16, 32) =]]
188213
```
214+
``` php hl_lines="22-24"
215+
// ...
216+
[[= include_code('code_samples/api/public_php_api/src/Controller/CustomController.php', 5, 12) =]]
217+
// ...
218+
[[= include_code('code_samples/api/public_php_api/src/Controller/CustomController.php', 17, 32) =]]
219+
```
189220

190221
The rendering of results is then relegated to [templates](templates.md) (lines 22-24).
191222

@@ -196,6 +227,12 @@ When using Repository filtering, provide the results of `ContentService::find()`
196227
[[= include_file('code_samples/api/public_php_api/src/Controller/CustomFilterController.php', 4, 12) =]] // ...
197228
[[= include_file('code_samples/api/public_php_api/src/Controller/CustomFilterController.php', 16, 31) =]]
198229
```
230+
``` php hl_lines="19"
231+
// ...
232+
[[= include_code('code_samples/api/public_php_api/src/Controller/CustomFilterController.php', 5, 12) =]]
233+
// ...
234+
[[= include_code('code_samples/api/public_php_api/src/Controller/CustomFilterController.php', 17, 31) =]]
235+
```
199236

200237
### Paginate search results
201238

@@ -206,12 +243,21 @@ To paginate search or filtering results, it's recommended to use the [Pagerfanta
206243
[[= include_file('code_samples/api/public_php_api/src/Controller/PaginationController.php', 8, 15) =]] // ...
207244
[[= include_file('code_samples/api/public_php_api/src/Controller/PaginationController.php', 19, 39) =]]
208245
```
246+
``` php
247+
// ...
248+
[[= include_code('code_samples/api/public_php_api/src/Controller/PaginationController.php', 9, 15) =]]
249+
// ...
250+
[[= include_code('code_samples/api/public_php_api/src/Controller/PaginationController.php', 20, 39) =]]
251+
```
209252

210253
Pagination can then be rendered for example using the following template:
211254

212255
``` html+twig
213256
[[= include_file('code_samples/api/public_php_api/templates/themes/standard/full/custom_pagination.html.twig') =]]
214257
```
258+
``` html+twig
259+
[[= include_code('code_samples/api/public_php_api/templates/themes/standard/full/custom_pagination.html.twig') =]]
260+
```
215261

216262
For more information and examples, see [PagerFanta documentation](https://www.babdev.com/open-source/packages/pagerfanta/docs/2.x/usage).
217263

@@ -244,6 +290,12 @@ You can do it using logical operators: `LogicalAnd`, `LogicalOr`, and `LogicalNo
244290
[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 44, 49) =]][[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 53, 54) =]]
245291
[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 60, 65) =]]
246292

293+
```
294+
``` php
295+
[[= include_code('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 45, 49) =]]
296+
[[= include_code('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 54, 54) =]]
297+
298+
[[= include_code('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 61, 65) =]]
247299
```
248300

249301
This example takes three parameters from a command — `$text`, `$contentTypeId`, and `$locationId`.
@@ -259,6 +311,9 @@ that doesn't belong to the provided Section:
259311
``` php
260312
[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 46, 54) =]]
261313
```
314+
``` php
315+
[[= include_code('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 47, 54) =]]
316+
```
262317

263318
### Combine independent Criteria
264319

@@ -292,6 +347,9 @@ For example, to order search results by their publication date, from oldest to n
292347
``` php
293348
[[= include_file('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 55, 59) =]]
294349
```
350+
``` php
351+
[[= include_code('code_samples/api/public_php_api/src/Command/FindComplexCommand.php', 56, 59) =]]
352+
```
295353

296354
!!! tip
297355

@@ -310,6 +368,9 @@ To do this, you use of the query's `$aggregations` property:
310368
``` php
311369
[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 30, 35) =]]
312370
```
371+
``` php
372+
[[= include_code('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 31, 35) =]]
373+
```
313374

314375
The name of the aggregation must be unique in the given query.
315376

@@ -318,12 +379,18 @@ Access the results by using the `get()` method of the aggregation:
318379
``` php
319380
[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 39, 40) =]]
320381
```
382+
``` php
383+
[[= include_code('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 40, 40) =]]
384+
```
321385

322386
Aggregation results contain the name of the result and the count of found items:
323387

324388
``` php
325389
[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 42, 45) =]]
326390
```
391+
``` php
392+
[[= include_code('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 43, 45) =]]
393+
```
327394

328395
With field aggregations you can group search results according to the value of a specific field.
329396
In this case the aggregation takes the content type identifier and the field identifier as parameters.
@@ -333,13 +400,19 @@ The following example creates an aggregation named `selection` that groups resul
333400
``` php
334401
[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 35, 36) =]]
335402
```
403+
``` php
404+
[[= include_code('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 36, 36) =]]
405+
```
336406

337407
With term aggregation you can define additional limits to the results.
338408
The following example limits the number of terms returned to 5 and only considers terms that have 10 or more results:
339409

340410
``` php
341411
[[= include_file('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 30, 33) =]]
342412
```
413+
``` php
414+
[[= include_code('code_samples/api/public_php_api/src/Command/FindWithAggregationCommand.php', 31, 33) =]]
415+
```
343416

344417
To use a range aggregation, you must provide a `ranges` array containing a set of `Range` objects that define the borders of the specific range sets.
345418

@@ -396,6 +469,9 @@ This example shows a minimal embedding query executed directly through the searc
396469
``` php hl_lines="38-39 41-47 49"
397470
[[= include_file('code_samples/api/public_php_api/src/Command/FindByTaxonomyEmbeddingCommand.php') =]]
398471
```
472+
``` php hl_lines="38-39 41-47 49"
473+
[[= include_code('code_samples/api/public_php_api/src/Command/FindByTaxonomyEmbeddingCommand.php') =]]
474+
```
399475

400476
For more information, see [Embeddings reference](embeddings_reference.md).
401477

@@ -414,6 +490,11 @@ For a list of supported Criteria and Sort Clauses, see [Search in trash referenc
414490
[[= include_file('code_samples/api/public_php_api/src/Command/FindInTrashCommand.php', 4, 6) =]]//...
415491
[[= include_file('code_samples/api/public_php_api/src/Command/FindInTrashCommand.php', 35, 42) =]]
416492
```
493+
``` php
494+
[[= include_code('code_samples/api/public_php_api/src/Command/FindInTrashCommand.php', 5, 6) =]]
495+
//...
496+
[[= include_code('code_samples/api/public_php_api/src/Command/FindInTrashCommand.php', 36, 42) =]]
497+
```
417498

418499
!!! caution
419500

0 commit comments

Comments
 (0)