/** * Create a new InterventionRequest object. * * @param Configuration $configuration * @param Request|null $request * @param LoggerInterface|null $logger * @param array|null $processors */ public function __construct(Configuration $configuration, Request $request = null, LoggerInterface $logger = null, array $processors = null) { $this->logger = $logger; $this->dispatcher = new EventDispatcher(); if (null !== $request) { $this->request = $request; } else { $this->request = Request::createFromGlobals(); } $this->configuration = $configuration; $this->dispatcher->addSubscriber(new JpegFileListener($this->configuration->getJpegoptimPath())); $this->dispatcher->addSubscriber(new PngFileListener($this->configuration->getPngquantPath())); $this->defineTimezone(); if (null === $processors) { $this->processors = [new Processor\RotateProcessor($this->request), new Processor\CropResizedProcessor($this->request), new Processor\FitProcessor($this->request), new Processor\CropProcessor($this->request), new Processor\WidenProcessor($this->request), new Processor\HeightenProcessor($this->request), new Processor\LimitColorsProcessor($this->request), new Processor\GreyscaleProcessor($this->request), new Processor\ContrastProcessor($this->request), new Processor\BlurProcessor($this->request), new Processor\SharpenProcessor($this->request), new Processor\ProgressiveProcessor($this->request)]; } elseif (is_array($processors)) { $this->processors = $processors; } }