/** * @param $media */ private function removeOldReference(Media $media) { $path = $media->getOldReferencePath(); if ($this->filesystem->has($path)) { $this->filesystem->delete($path); } }
/** * @param Media $media * @throws \Exception */ public function generateThumbnails(Media $media) { $context = $media->getContext(); if (!array_key_exists($context, $this->contextConfiguration)) { throw new \Exception('Supplied context does not exist'); } $formats = $this->contextConfiguration[$context]['formats']; $referencePath = $this->locator->getReferencePath($media); $referenceBinaryData = $this->filesystem->read($referencePath); foreach ($formats as $name => $settings) { $path = $this->locator->getThumbnailPath($media, $name); $data = $this->generateThumbnail($referenceBinaryData, $settings); $this->filesystem->writeContent($path, $data); } }