vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/TwigBundle.php line 43

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  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 Symfony\Bundle\TwigBundle;
  11. use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\ExceptionListenerPass;
  12. use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\ExtensionPass;
  13. use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\RuntimeLoaderPass;
  14. use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\TwigEnvironmentPass;
  15. use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\TwigLoaderPass;
  16. use Symfony\Component\Console\Application;
  17. use Symfony\Component\DependencyInjection\Compiler\PassConfig;
  18. use Symfony\Component\DependencyInjection\ContainerBuilder;
  19. use Symfony\Component\HttpKernel\Bundle\Bundle;
  20. use Twig\Cache\FilesystemCache;
  21. use Twig\Extension\CoreExtension;
  22. use Twig\Extension\EscaperExtension;
  23. use Twig\Extension\OptimizerExtension;
  24. use Twig\Extension\StagingExtension;
  25. use Twig\ExtensionSet;
  26. // Help opcache.preload discover always-needed symbols
  27. class_exists(FilesystemCache::class);
  28. class_exists(CoreExtension::class);
  29. class_exists(EscaperExtension::class);
  30. class_exists(OptimizerExtension::class);
  31. class_exists(StagingExtension::class);
  32. class_exists(ExtensionSet::class);
  33. /**
  34.  * Bundle.
  35.  *
  36.  * @author Fabien Potencier <fabien@symfony.com>
  37.  */
  38. class TwigBundle extends Bundle
  39. {
  40.     public function build(ContainerBuilder $container)
  41.     {
  42.         parent::build($container);
  43.         // ExtensionPass must be run before the FragmentRendererPass as it adds tags that are processed later
  44.         $container->addCompilerPass(new ExtensionPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION10);
  45.         $container->addCompilerPass(new TwigEnvironmentPass());
  46.         $container->addCompilerPass(new TwigLoaderPass());
  47.         $container->addCompilerPass(new ExceptionListenerPass());
  48.         $container->addCompilerPass(new RuntimeLoaderPass(), PassConfig::TYPE_BEFORE_REMOVING);
  49.     }
  50.     public function registerCommands(Application $application)
  51.     {
  52.         // noop
  53.     }
  54. }