vendor/twig/extra-bundle/TwigExtraBundle.php line 34

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) Fabien Potencier
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Twig\Extra\TwigExtraBundle;
  11. use Symfony\Component\DependencyInjection\Compiler\PassConfig;
  12. use Symfony\Component\DependencyInjection\ContainerBuilder;
  13. use Symfony\Component\HttpKernel\Bundle\Bundle;
  14. use Symfony\Component\HttpKernel\KernelInterface;
  15. use Twig\Extra\TwigExtraBundle\DependencyInjection\Compiler\MissingExtensionSuggestorPass;
  16. use Twig\Extra\TwigExtraBundle\DependencyInjection\Compiler\TwigCachePoolPass;
  17. if (method_exists(KernelInterface::class, 'getShareDir')) {
  18. class TwigExtraBundle extends Bundle
  19. {
  20. public function build(ContainerBuilder $container): void
  21. {
  22. parent::build($container);
  23. $container->addCompilerPass(new MissingExtensionSuggestorPass());
  24. // priority 64 so that it runs before Symfony's CachePoolPass (priority 32)
  25. $container->addCompilerPass(new TwigCachePoolPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 64);
  26. }
  27. }
  28. } else {
  29. class TwigExtraBundle extends Bundle
  30. {
  31. /** @return void */
  32. public function build(ContainerBuilder $container)
  33. {
  34. parent::build($container);
  35. $container->addCompilerPass(new MissingExtensionSuggestorPass());
  36. // priority 64 so that it runs before Symfony's CachePoolPass (priority 32)
  37. $container->addCompilerPass(new TwigCachePoolPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 64);
  38. }
  39. }
  40. }