/** * Creates a new image store helper * * @param array $imageSizes * @param SizedPathService $pathService * @param string $imageType * @param int $defaultImageQuality * * @throws \InvalidArgumentException if an invalid image type is given */ public function __construct(array $imageSizes, SizedPathService $pathService, $imageType = "jpg", $defaultImageQuality = 85) { if (!ImageHandler::isSupportedImageType($imageType)) { throw new \InvalidArgumentException("Image type not supported: {$imageType}. Supported image types are: " . implode(", ", ImageHandler::getSupportedImageTypes())); } $this->imageSizes = $imageSizes; $this->pathService = $pathService; $this->imageType = $imageType; $this->defaultImageQuality = $defaultImageQuality; }
/** * Constructs a new simple sized path service * * @param \Symfony\Component\HttpKernel\KernelInterface $kernel * @param \Symfony\Component\HttpFoundation\Request $request * @param string $relativePath the relative path from the web dir * @param string $imageType the image type, on of the ImageHandler::IMAGE_TYPE_* constants * @param string|null $hashPrefix prefix for file name hashing. No hashing is applied to the filename, if $hashPrefix is null * * @throws \InvalidArgumentException */ public function __construct(KernelInterface $kernel, Request $request, $relativePath, $imageType, $hashPrefix = null) { parent::__construct($kernel, $request); if (!ImageHandler::isSupportedImageType($imageType)) { throw new \InvalidArgumentException("Image type not supported: {$imageType}. Supported image types are: " . implode(", ", ImageHandler::getSupportedImageTypes())); } $this->imageType = $imageType; $this->hashPrefix = $hashPrefix; $this->relativePath = trim($relativePath, "/"); }