/** * @param File|null $originalResource * @return File */ public function duplicate($originalResource) { if (!$originalResource) { return null; } /** @var File $newFile */ $newFile = $this->createNew(); $newFile->setMimeType($originalResource->getMimeType()); $newFile->setExtension($originalResource->getExtension()); $newFile->setOrder($originalResource->getOrder()); $newFile->setFilename($originalResource->getFilename()); $newFile->setSlug($originalResource->getSlug()); $newFile->setParameters($originalResource->getParameters()); $newFile->setGarbage(false); $newFile->setGarbageTimestamp(new \DateTime()); $this->entityManager->persist($newFile); $this->entityManager->flush(); copy($this->mediaPath . '/' . $originalResource->getId(), $this->mediaPath . '/' . $newFile->getId()); return $newFile; }
protected function getFileInfo(EnhavoFile $file) { $info = array(); $info['id'] = $file->getId(); $info['mimeType'] = $file->getMimeType(); $info['extension'] = $file->getExtension(); $info['filename'] = $file->getFilename(); $info['slug'] = $file->getSlug(); return $info; }
public function getMediaExtension(File $file) { return strtolower($file->getExtension()); }