コード例 #1
0
 /**
  * Transforms the value the users has typed to a value that suits the field in the Document
  *
  * @param mixed $data
  *
  * @return Media|null
  */
 public function reverseTransform($data)
 {
     if (!is_numeric($data)) {
         return null;
     }
     $defaultProvider = $this->mediaManager->getDefaultProviderInstance();
     $fetched = $defaultProvider->find($data);
     if ($fetched instanceof Media) {
         return $fetched;
     }
     return null;
 }
コード例 #2
0
 /**
  * Transforms the value the users has typed to a value that suits the field in the Document
  */
 public function reverseTransform($data)
 {
     if ($data instanceof Media) {
         return $data;
         if (!$data->getId() && $data->getHash()) {
             $defaultProvider = $this->mediaManager->getDefaultProviderInstance();
             $fetched = $defaultProvider->findByHash($data->getHash());
             if ($fetched instanceof Media) {
                 $fetched->setTitle($data->getTitle());
                 $fetched->setAlt($data->getAlt());
                 $fetched->setCredits($data->getCredits());
                 $data = $fetched;
             }
         }
     }
     return $data;
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('class' => $this->mediaManager->getDefaultProviderInstance()->getEntityClass(), 'property' => 'title'));
 }
コード例 #4
0
 /**
  * @param OptionsResolverInterface $resolver
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $defaultProvider = $this->mediaManager->getDefaultProviderInstance();
     $resolver->setDefaults(array('label' => false, 'data_class' => $defaultProvider->getCategoryEntityClass()));
 }