filesystem = $filesystem; $this->alchemyst = $alchemyst; $this->booker = new LazaretPathBooker($filesystem, $tmpPath); } /** * Write a file in storage and mark it lazaret * @param File $file * @return PersistedLazaretInformation */ public function writeLazaret(File $file) { $lazaretPathname = $this->booker->bookFile($file->getOriginalName()); $this->filesystem->copy($file->getFile()->getRealPath(), $lazaretPathname, true); $lazaretPathnameThumb = $this->booker->bookFile($file->getOriginalName(), 'thumb'); try { $this->alchemyst->turnInto($file->getFile()->getPathname(), $lazaretPathnameThumb, $this->createThumbnailSpecification()); } catch (ExceptionInterface $e) { // Ignore, an empty file should be present } return new PersistedLazaretInformation($lazaretPathname, $lazaretPathnameThumb); } /** * @return ImageSpecification */ private function createThumbnailSpecification() { $spec = new ImageSpecification(); $spec->setResizeMode(ImageSpecification::RESIZE_MODE_INBOUND_FIXEDRATIO); $spec->setDimensions(375, 275); return $spec; } }