vendor/liip/imagine-bundle/LiipImagineBundle.php line 40

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the `liip/LiipImagineBundle` project.
  4.  *
  5.  * (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE.md
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Liip\ImagineBundle;
  11. use Enqueue\Bundle\DependencyInjection\Compiler\AddTopicMetaPass;
  12. use Liip\ImagineBundle\Async\Topics;
  13. use Liip\ImagineBundle\Binary\Loader\LoaderInterface as BinaryLoaderInterface;
  14. use Liip\ImagineBundle\DependencyInjection\Compiler\AssetsVersionCompilerPass;
  15. use Liip\ImagineBundle\DependencyInjection\Compiler\DriverCompilerPass;
  16. use Liip\ImagineBundle\DependencyInjection\Compiler\FiltersCompilerPass;
  17. use Liip\ImagineBundle\DependencyInjection\Compiler\LoadersCompilerPass;
  18. use Liip\ImagineBundle\DependencyInjection\Compiler\MaybeSetMimeServicesAsAliasesCompilerPass;
  19. use Liip\ImagineBundle\DependencyInjection\Compiler\MetadataReaderCompilerPass;
  20. use Liip\ImagineBundle\DependencyInjection\Compiler\NonFunctionalFilterExceptionPass;
  21. use Liip\ImagineBundle\DependencyInjection\Compiler\PostProcessorsCompilerPass;
  22. use Liip\ImagineBundle\DependencyInjection\Compiler\ResolversCompilerPass;
  23. use Liip\ImagineBundle\DependencyInjection\Factory\Loader\ChainLoaderFactory;
  24. use Liip\ImagineBundle\DependencyInjection\Factory\Loader\FileSystemLoaderFactory;
  25. use Liip\ImagineBundle\DependencyInjection\Factory\Loader\FlysystemLoaderFactory;
  26. use Liip\ImagineBundle\DependencyInjection\Factory\Loader\StreamLoaderFactory;
  27. use Liip\ImagineBundle\DependencyInjection\Factory\Resolver\AwsS3ResolverFactory;
  28. use Liip\ImagineBundle\DependencyInjection\Factory\Resolver\FlysystemResolverFactory;
  29. use Liip\ImagineBundle\DependencyInjection\Factory\Resolver\WebPathResolverFactory;
  30. use Liip\ImagineBundle\DependencyInjection\LiipImagineExtension;
  31. use Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface as LoaderLoaderInterface;
  32. use Liip\ImagineBundle\Imagine\Filter\PostProcessor\PostProcessorInterface;
  33. use Symfony\Component\DependencyInjection\Compiler\PassConfig;
  34. use Symfony\Component\DependencyInjection\ContainerBuilder;
  35. use Symfony\Component\HttpKernel\Bundle\Bundle;
  36. class LiipImagineBundle extends Bundle
  37. {
  38.     public function build(ContainerBuilder $container): void
  39.     {
  40.         parent::build($container);
  41.         $container->addCompilerPass(new NonFunctionalFilterExceptionPass());
  42.         $container->addCompilerPass(new AssetsVersionCompilerPass(), PassConfig::TYPE_BEFORE_REMOVING);
  43.         $container->addCompilerPass(new DriverCompilerPass());
  44.         $container->addCompilerPass(new LoadersCompilerPass());
  45.         $container->addCompilerPass(new FiltersCompilerPass());
  46.         $container->addCompilerPass(new PostProcessorsCompilerPass());
  47.         $container->addCompilerPass(new ResolversCompilerPass());
  48.         $container->addCompilerPass(new MetadataReaderCompilerPass());
  49.         $container->addCompilerPass(new MaybeSetMimeServicesAsAliasesCompilerPass());
  50.         if (class_exists(AddTopicMetaPass::class)) {
  51.             $container->addCompilerPass(AddTopicMetaPass::create()
  52.                 ->add(Topics::CACHE_RESOLVED'The topic contains messages about resolved image\'s caches')
  53.             );
  54.         }
  55.         /** @var $extension LiipImagineExtension */
  56.         $extension $container->getExtension('liip_imagine');
  57.         $extension->addResolverFactory(new WebPathResolverFactory());
  58.         $extension->addResolverFactory(new AwsS3ResolverFactory());
  59.         $extension->addResolverFactory(new FlysystemResolverFactory());
  60.         $extension->addLoaderFactory(new StreamLoaderFactory());
  61.         $extension->addLoaderFactory(new FileSystemLoaderFactory());
  62.         $extension->addLoaderFactory(new FlysystemLoaderFactory());
  63.         $extension->addLoaderFactory(new ChainLoaderFactory());
  64.         $container->registerForAutoconfiguration(LoaderLoaderInterface::class)->addTag('liip_imagine.filter.loader');
  65.         $container->registerForAutoconfiguration(PostProcessorInterface::class)->addTag('liip_imagine.filter.post_processor');
  66.         $container->registerForAutoconfiguration(BinaryLoaderInterface::class)->addTag('liip_imagine.binary.loader');
  67.     }
  68. }