FrameworkBundle.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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\FrameworkBundle;
  11. use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConstraintValidatorsPass;
  12. use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddValidatorInitializersPass;
  13. use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\FormPass;
  14. use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TemplatingPass;
  15. use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RegisterKernelListenersPass;
  16. use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RoutingResolverPass;
  17. use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass;
  18. use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass;
  19. use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass;
  20. use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass;
  21. use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CompilerDebugDumpPass;
  22. use Symfony\Component\DependencyInjection\ContainerBuilder;
  23. use Symfony\Component\DependencyInjection\Compiler\PassConfig;
  24. use Symfony\Component\DependencyInjection\Scope;
  25. use Symfony\Component\HttpFoundation\Request;
  26. use Symfony\Component\HttpKernel\Bundle\Bundle;
  27. /**
  28. * Bundle.
  29. *
  30. * @author Fabien Potencier <fabien@symfony.com>
  31. */
  32. class FrameworkBundle extends Bundle
  33. {
  34. public function boot()
  35. {
  36. if ($this->container->getParameter('kernel.proxy')) {
  37. Request::trustProxyData();
  38. }
  39. }
  40. public function build(ContainerBuilder $container)
  41. {
  42. parent::build($container);
  43. $container->addScope(new Scope('request'));
  44. $container->addCompilerPass(new RoutingResolverPass());
  45. $container->addCompilerPass(new ProfilerPass());
  46. $container->addCompilerPass(new RegisterKernelListenersPass());
  47. $container->addCompilerPass(new TemplatingPass());
  48. $container->addCompilerPass(new AddConstraintValidatorsPass());
  49. $container->addCompilerPass(new AddValidatorInitializersPass());
  50. $container->addCompilerPass(new FormPass());
  51. $container->addCompilerPass(new TranslatorPass());
  52. $container->addCompilerPass(new AddCacheWarmerPass());
  53. if ($container->getParameter('kernel.debug')) {
  54. $container->addCompilerPass(new ContainerBuilderDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING);
  55. $container->addCompilerPass(new CompilerDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING);
  56. }
  57. }
  58. }