| 123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- declare(strict_types=1);
- namespace App\Service\File\Manager;
- use ApiPlatform\Api\IriConverterInterface;
- use App\Entity\Core\File;
- use App\Service\File\Exception\FileNotFoundException;
- use App\Service\File\Factory\ImageFactory;
- use App\Service\ServiceIterator\StorageIterator;
- class ImageManager extends AbstractFileManager
- {
- public function __construct(
- IriConverterInterface $iriConverter,
- StorageIterator $storageIterator,
- private ImageFactory $imageFactory
- )
- {
- parent::__construct($iriConverter, $storageIterator);
- }
- /**
- * Lit le fichier et retourne son contenu
- *
- * @param File $file
- * @return string
- * @throws FileNotFoundException
- */
- public function read(File $file, int $height = 0, int $width = 0): string
- {
- $storage = $this->getStorageFor($file);
- $binary = $storage->getBinaryImage($file);
- return $this->imageFactory->create($binary, $file->getConfig(), $height, $width);
- }
- }
|