TwigBundle.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. /**
  20. * Bundle.
  21. *
  22. * @author Fabien Potencier <fabien@symfony.com>
  23. */
  24. class TwigBundle extends Bundle
  25. {
  26. public function build(ContainerBuilder $container)
  27. {
  28. parent::build($container);
  29. // ExtensionPass must be run before the FragmentRendererPass as it adds tags that are processed later
  30. $container->addCompilerPass(new ExtensionPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 10);
  31. $container->addCompilerPass(new TwigEnvironmentPass());
  32. $container->addCompilerPass(new TwigLoaderPass());
  33. $container->addCompilerPass(new RuntimeLoaderPass(), PassConfig::TYPE_BEFORE_REMOVING);
  34. }
  35. public function registerCommands(Application $application)
  36. {
  37. // noop
  38. }
  39. }