Exemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function upload($obj, PropertyMapping $mapping)
 {
     $file = $mapping->getFile($obj);
     if ($file === null || !$file instanceof UploadedFile) {
         throw new \LogicException('No uploadable file found');
     }
     // determine the file's name
     if ($mapping->hasNamer()) {
         $name = $mapping->getNamer()->name($obj, $mapping);
     } else {
         $name = $file->getClientOriginalName();
     }
     $mapping->setFileName($obj, $name);
     // determine the file's directory
     $dir = $mapping->getUploadDir($obj);
     $this->doUpload($mapping, $file, $dir, $name);
 }