Rename caption metadata and use preloaded values

This commit is contained in:
Thibaud Fabre
2016-07-02 14:53:40 +02:00
parent 0bc38c9dd2
commit 7141d4c1d5
2 changed files with 7 additions and 5 deletions

View File

@@ -1102,6 +1102,7 @@ class V1Controller extends Controller
'results.stories' => $storyTransformer,
'results.stories.thumbnail' => $subdefTransformer,
'results.stories.metadatas' => new CallbackTransformer(),
'results.stories.caption' => new CallbackTransformer(),
'results.stories.records' => $recordTransformer,
'results.stories.records.thumbnail' => $subdefTransformer,
'results.stories.records.technical_informations' => $technicalDataTransformer,
@@ -1244,7 +1245,8 @@ class V1Controller extends Controller
}
}
if (in_array('results.stories.metadatas', $includes, true)) {
if (in_array('results.stories.metadatas', $includes, true) ||
in_array('results.stories.caption', $includes, true)) {
$captions = $this->app['service.caption']->findByReferenceCollection($stories);
$canSeeBusiness = $this->retrieveSeeBusinessPerDatabox($stories);
@@ -1421,7 +1423,7 @@ class V1Controller extends Controller
]);
}
else {
$includes[] = 'results.stories.caption_metadata';
$includes[] = 'results.stories.caption';
}
$includes = array_merge($includes, [

View File

@@ -18,7 +18,7 @@ class StoryTransformer extends TransformerAbstract
/**
* @var array
*/
protected $availableIncludes = ['thumbnail', 'metadatas', 'records', 'caption_metadatas'];
protected $availableIncludes = ['thumbnail', 'metadatas', 'records', 'caption'];
/**
* @var array
@@ -77,9 +77,9 @@ class StoryTransformer extends TransformerAbstract
return $this->collection($storyView->getChildren(), $this->recordTransformer);
}
public function includeCaptionMetadatas(StoryView $storyView)
public function includeCaption(StoryView $storyView)
{
return $this->collection($storyView->getStory()->get_caption()->get_fields(), $this->getCaptionRecordTransformer());
return $this->collection($storyView->getCaption()->getFields(), $this->getCaptionRecordTransformer());
}
private function getCaptionRecordTransformer()