Exemple #1
0
 /**
  * @param Repository   $repository
  * @param \SplFileInfo $file
  * @param array        $context
  */
 public function __construct(Repository $repository, \SplFileInfo $file, array $context = array())
 {
     $this->repository = $repository;
     $this->storageKey = $repository->generateStorageKey($file, $context);
     if (!$this->storageKey) {
         throw new \RuntimeException('No storage key has been generated!');
     }
     $this->createdAt = new \DateTime('now');
     $this->filename = $file->getFilename();
     $this->extension = $file->getExtension();
     $this->alternatives = new ArrayCollection();
     if ($file instanceof File) {
         $this->mimeType = $file->getMimeType();
     }
     if ($file instanceof UploadedFile) {
         $this->filename = $file->getClientOriginalName();
         $this->extension = $file->getClientOriginalExtension();
     }
 }