Include caption metadatas in search type 2

This commit is contained in:
Thibaud Fabre
2016-07-02 14:35:47 +02:00
parent 0679bd83b5
commit 0bc38c9dd2
2 changed files with 20 additions and 1 deletions

View File

@@ -1420,6 +1420,9 @@ class V1Controller extends Controller
'results.stories.records.status'
]);
}
else {
$includes[] = 'results.stories.caption_metadata';
}
$includes = array_merge($includes, [
'results.records.subdefs',

View File

@@ -18,7 +18,7 @@ class StoryTransformer extends TransformerAbstract
/**
* @var array
*/
protected $availableIncludes = ['thumbnail', 'metadatas', 'records'];
protected $availableIncludes = ['thumbnail', 'metadatas', 'records', 'caption_metadatas'];
/**
* @var array
@@ -77,6 +77,22 @@ class StoryTransformer extends TransformerAbstract
return $this->collection($storyView->getChildren(), $this->recordTransformer);
}
public function includeCaptionMetadatas(StoryView $storyView)
{
return $this->collection($storyView->getStory()->get_caption()->get_fields(), $this->getCaptionRecordTransformer());
}
private function getCaptionRecordTransformer()
{
return function (\caption_field $captionField) {
return [
'meta_structure_id' => $captionField->get_meta_struct_id(),
'name' => $captionField->get_name(),
'value' => $captionField->get_serialized_values(';')
];
};
}
/**
* @return \Closure
*/