Ejemplo n.º 1
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;
 }