/**
  * Creates the property mapping from the read annotation and configured mapping.
  *
  * @param object $obj The object.
  * @param \Vich\UploaderBundle\Annotation\UploadableField $field The read annotation.
  * @return PropertyMapping The property mapping.
  * @throws \InvalidArgumentException
  */
 protected function createMapping($obj, UploadableField $field)
 {
     $class = $this->adapter->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();
     $mapping->setProperty($class->getProperty($field->getPropertyName()));
     $mapping->setFileNameProperty($class->getProperty($field->getFileNameProperty()));
     $mapping->setMappingName($field->getMapping());
     $mapping->setMapping($config);
     if ($config['namer']) {
         $mapping->setNamer($this->container->get($config['namer']));
     }
     return $mapping;
 }