From 7141d4c1d57c09f7fb307d810762455198f51e66 Mon Sep 17 00:00:00 2001 From: Thibaud Fabre Date: Sat, 2 Jul 2016 14:53:40 +0200 Subject: [PATCH] Rename caption metadata and use preloaded values --- lib/Alchemy/Phrasea/Controller/Api/V1Controller.php | 6 ++++-- lib/Alchemy/Phrasea/Search/StoryTransformer.php | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php index f1a74b1830..ed0be66d59 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php +++ b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php @@ -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, [ diff --git a/lib/Alchemy/Phrasea/Search/StoryTransformer.php b/lib/Alchemy/Phrasea/Search/StoryTransformer.php index 192d8e3687..79f8aae9a7 100644 --- a/lib/Alchemy/Phrasea/Search/StoryTransformer.php +++ b/lib/Alchemy/Phrasea/Search/StoryTransformer.php @@ -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()