FrameworkBundle.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Symfony\Bundle\FrameworkBundle;
  3. use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddSecurityVotersPass;
  4. use Symfony\Component\DependencyInjection\ContainerBuilder;
  5. use Symfony\Component\HttpKernel\Bundle\Bundle;
  6. use Symfony\Component\Form\FormConfiguration;
  7. /*
  8. * This file is part of the Symfony framework.
  9. *
  10. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  11. *
  12. * This source file is subject to the MIT license that is bundled
  13. * with this source code in the file LICENSE.
  14. */
  15. /**
  16. * Bundle.
  17. *
  18. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  19. */
  20. class FrameworkBundle extends Bundle
  21. {
  22. /**
  23. * Boots the Bundle.
  24. */
  25. public function boot()
  26. {
  27. if ($this->container->has('error_handler')) {
  28. $this->container->get('error_handler');
  29. }
  30. if ($this->container->hasParameter('csrf_secret')) {
  31. FormConfiguration::setDefaultCsrfSecret($this->container->getParameter('csrf_secret'));
  32. FormConfiguration::enableDefaultCsrfProtection();
  33. }
  34. }
  35. public function registerExtensions(ContainerBuilder $container)
  36. {
  37. parent::registerExtensions($container);
  38. $container->addCompilerPass(new AddSecurityVotersPass());
  39. }
  40. }