diff --git a/config/services.yml b/config/services.yml index 72e61a0..8d9b11c 100644 --- a/config/services.yml +++ b/config/services.yml @@ -9,7 +9,7 @@ services: Intervention\Image\ImageManager: arguments: - - { driver: '%rz_intervention_request.driver%' } + - '@Intervention\Image\Interfaces\DriverInterface' RZ\InterventionRequestBundle\Command\CacheCommand: arguments: diff --git a/src/DependencyInjection/RZInterventionRequestExtension.php b/src/DependencyInjection/RZInterventionRequestExtension.php index b49a1a3..a001b8b 100644 --- a/src/DependencyInjection/RZInterventionRequestExtension.php +++ b/src/DependencyInjection/RZInterventionRequestExtension.php @@ -4,9 +4,11 @@ namespace RZ\InterventionRequestBundle\DependencyInjection; +use Intervention\Image\Interfaces\DriverInterface; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Loader; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\DependencyInjection\Extension; @@ -35,6 +37,10 @@ public function load(array $configs, ContainerBuilder $container): void $container->setParameter('rz_intervention_request.jpegoptim_path', $config['jpegoptim_path']); $container->setParameter('rz_intervention_request.pngquant_path', $config['pngquant_path']); + $driverDefinition = new Definition(DriverInterface::class); + $driverDefinition->setClass(('imagick' === $config['driver']) ? \Intervention\Image\Drivers\Imagick\Driver::class : \Intervention\Image\Drivers\Gd\Driver::class); + $container->setDefinition(DriverInterface::class, $driverDefinition); + $this->loadSubscribers($container, $config); }