vendor/symfony/twig-bundle/TwigBundle.php line 42

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