File tree Expand file tree Collapse file tree 4 files changed +90
-7
lines changed Expand file tree Collapse file tree 4 files changed +90
-7
lines changed Original file line number Diff line number Diff line change @@ -400,10 +400,36 @@ paths:
400
400
401
401
### results.records.technical_informations
402
402
always included
403
-
403
+
404
404
_nb:_ since stories are not related to a document, there is no technical_informations for stories.
405
-
406
- ### results.records.children
405
+
406
+ ### results.records.stories
407
+ Include a list of stories that contains the record
408
+
409
+ stories is an array of small objects containing only the `story_id` (= `record_id`) of the story.
410
+ ```
411
+ "response": {
412
+ "results": {
413
+ "records": [
414
+ {
415
+ "stories": [
416
+ {
417
+ "story_id": 100
418
+ },
419
+ {
420
+ "story_id": 102
421
+ },
422
+ ...
423
+ ],
424
+ ...
425
+ },
426
+ ...
427
+ ]
428
+ }
429
+ }
430
+ ```
431
+
432
+ ### results.stories.children
407
433
In story search mode, will publish a children[] array for each result. See _story_children_limit_ parameter.
408
434
409
435
children is an array of records, with same structure as a result record.
Original file line number Diff line number Diff line change @@ -443,10 +443,36 @@ paths:
443
443
444
444
### results.records.technical_informations
445
445
always included
446
-
446
+
447
447
_nb:_ since stories are not related to a document, there is no technical_informations for stories.
448
-
449
- ### results.records.children
448
+
449
+ ### results.records.stories
450
+ Include a list of stories that contains the record
451
+
452
+ stories is an array of small objects containing only the `story_id` (= `record_id`) of the story.
453
+ ```
454
+ "response": {
455
+ "results": {
456
+ "records": [
457
+ {
458
+ "stories": [
459
+ {
460
+ "story_id": 100
461
+ },
462
+ {
463
+ "story_id": 102
464
+ },
465
+ ...
466
+ ],
467
+ ...
468
+ },
469
+ ...
470
+ ]
471
+ }
472
+ }
473
+ ```
474
+
475
+ ### results.stories.children
450
476
In story search mode, will publish a children[] array for each result. See _story_children_limit_ parameter.
451
477
452
478
children is an array of records, with same structure as a result record.
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ public function searchAction(Request $request)
69
69
$ technicalDataTransformer = new TechnicalDataTransformer ();
70
70
$ recordTransformer = new RecordTransformer ($ subdefTransformer , $ technicalDataTransformer , $ this ->getResourceIdResolver ());
71
71
$ storyTransformer = new V3StoryTransformer ($ recordTransformer );
72
+ $ recordTransformer ->setStoryTransformer ($ storyTransformer );
72
73
$ compositeTransformer = new V3SearchCompositeResultTransformer ($ recordTransformer , $ storyTransformer );
73
74
$ searchTransformer = new V3SearchResultTransformer ($ compositeTransformer );
74
75
@@ -79,6 +80,9 @@ public function searchAction(Request $request)
79
80
'suggestions ' => new CallbackTransformer (),
80
81
'results.stories ' => $ storyTransformer ,
81
82
'results.stories.children ' => $ recordTransformer ,
83
+ 'results.records.stories ' => $ storyTransformer ,
84
+ 'results.records.stories.thumbnail ' => $ subdefTransformer ,
85
+ 'results.records.stories.metadata ' => new CallbackTransformer (),
82
86
'results.stories.children.thumbnail ' => $ subdefTransformer ,
83
87
'results.stories.children.technical_informations ' => $ technicalDataTransformer ,
84
88
'results.stories.children.subdefs ' => $ subdefTransformer ,
Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ class RecordTransformer extends TransformerAbstract
22
22
'metadata ' ,
23
23
// 'metadatas',
24
24
'status ' ,
25
- 'caption '
25
+ 'caption ' ,
26
+ 'stories '
26
27
];
27
28
28
29
protected $ defaultIncludes = [
@@ -45,6 +46,10 @@ class RecordTransformer extends TransformerAbstract
45
46
* @var callable
46
47
*/
47
48
private $ resourceIdResolver ;
49
+ /**
50
+ * @var V3StoryTransformer
51
+ */
52
+ private $ storyTransformer ;
48
53
49
54
public function __construct (SubdefTransformer $ subdefTransformer , TechnicalDataTransformer $ technicalDataTransformer , callable $ resourceIdResolver )
50
55
{
@@ -171,11 +176,33 @@ public function includeCaption(RecordView $recordView)
171
176
});
172
177
}
173
178
179
+ public function includeStories (RecordView $ recordView )
180
+ {
181
+ $ data = [];
182
+
183
+ /** @var record_adapter $story */
184
+ foreach ($ recordView ->getRecord ()->get_grouping_parents () as $ story ) {
185
+ $ data [] = [
186
+ // 'title' => $story->get_title(),
187
+ 'story_id ' => $ story ->getRecordId (),
188
+ ];
189
+ }
190
+
191
+ return $ this ->collection ($ data , function (array $ storyData ) {
192
+ return $ storyData ;
193
+ });
194
+ }
195
+
174
196
/**
175
197
* @return callable
176
198
*/
177
199
public function getResourceIdResolver (): callable
178
200
{
179
201
return $ this ->resourceIdResolver ;
180
202
}
203
+
204
+ public function setStoryTransformer (V3StoryTransformer $ storyTransformer )
205
+ {
206
+ $ this ->storyTransformer = $ storyTransformer ;
207
+ }
181
208
}
You can’t perform that action at this time.
0 commit comments