/**
  * Creates the property mapping from the read annotation and configured mapping.
  *
  * @param  object $obj The object.
  * @param  \ReflectionClass $class
  * @param  \Iphp\FileStoreBundle\Mapping\Annotation\UploadableField $field The read annotation.
  * @return \Iphp\FileStoreBundle\Mapping\PropertyMapping     The property mapping.
  * @throws \InvalidArgumentException
  */
 protected function createMapping($obj, \ReflectionClass $class, UploadableField $field)
 {
     if (!array_key_exists($field->getMapping(), $this->mappingsConfig)) {
         throw new \InvalidArgumentException(sprintf('No mapping named "%s" configured.', $field->getMapping()));
     }
     $config = $this->mappingsConfig[$field->getMapping()];
     $mapping = new PropertyMapping($obj, $config, $this->namerServiceInvoker);
     $mapping->setFileUploadProperty($class->getProperty($field->getFileUploadPropertyName()));
     $mapping->setFileDataProperty($class->getProperty($field->getFileDataPropertyName()));
     $mapping->setMappingName($field->getMapping());
     return $mapping;
 }
Ejemplo n.º 2
0
 /**
  * Creates the property mapping from the read annotation and configured mapping.
  *
  * @param  object                                          $obj   The object.
  * @param  \Iphp\FileStoreBundle\Mapping\Annotation\UploadableField $field The read annotation.
  * @return \Iphp\FileStoreBundle\Mapping\PropertyMapping     The property mapping.
  * @throws \InvalidArgumentException
  */
 protected function createMapping($obj, UploadableField $field)
 {
     $class = $this->dataStorage->getReflectionClass($obj);
     if (!array_key_exists($field->getMapping(), $this->mappings)) {
         throw new \InvalidArgumentException(sprintf('No mapping named "%s" configured.', $field->getMapping()));
     }
     $config = $this->mappings[$field->getMapping()];
     $mapping = new PropertyMapping($obj, $config, $this->container);
     $mapping->setProperty($class->getProperty($field->getPropertyName()));
     $mapping->setFileNameProperty($class->getProperty($field->getFileNameProperty()));
     $mapping->setMappingName($field->getMapping());
     return $mapping;
 }