public function testGetUnmappedStoryFieldReturnsEmptyString()
 {
     $map = new FieldMap(['ham' => ['en' => 'bacon']]);
     $helper = new MetadataHelper($map, 'en', 'en');
     $story = new Story();
     $story->setCaption(new ArrayCollection());
     $this->assertEquals('', $helper->getStoryField($story, 'eggs', 'en'));
 }
 public function getStoryField(Story $story, $field, $locale = null)
 {
     if (!$this->fieldsMap->hasAlias($field, $locale)) {
         return '';
     }
     $key = $this->fieldsMap->getFieldName($field, $locale);
     foreach ($story->getCaption() as $captionField) {
         if ($key === $captionField->getName()) {
             return $captionField->getValue();
         }
     }
 }
 /**
  * Fetch correct thumbnail according to type (medium or large)
  *
  * @param Record|Story $record Record for which to fetch the thumbnail
  * @param string $type Size of the thumbnail
  * @return null|\PhraseanetSDK\Entity\Subdef
  * @throws \InvalidArgumentException
  */
 public function fetch($record, $type)
 {
     if (!$record instanceof Record && !$record instanceof Story) {
         throw new \InvalidArgumentException();
     }
     if (!$this->thumbnailMap->hasSubDefinition($type) || $record instanceof Story) {
         return $record->getThumbnail();
     }
     $subdefinition = $this->thumbnailMap->getSubDefinition($type);
     if ($record->getSubdefs()->containsKey($subdefinition)) {
         return $record->getSubdefs()->get($subdefinition);
     }
     return $record->getThumbnail();
 }