Bundle.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace Symfony\Framework\WebBundle;
  3. use Symfony\Foundation\Bundle\Bundle as BaseBundle;
  4. use Symfony\Components\DependencyInjection\ContainerInterface;
  5. use Symfony\Components\DependencyInjection\Loader\Loader;
  6. use Symfony\Components\DependencyInjection\Loader\XmlFileLoader;
  7. use Symfony\Components\DependencyInjection\BuilderConfiguration;
  8. use Symfony\Framework\WebBundle\DependencyInjection\WebExtension;
  9. /*
  10. * This file is part of the Symfony framework.
  11. *
  12. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  13. *
  14. * This source file is subject to the MIT license that is bundled
  15. * with this source code in the file LICENSE.
  16. */
  17. /**
  18. * Bundle.
  19. *
  20. * @package Symfony
  21. * @subpackage Framework_WebBundle
  22. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  23. */
  24. class Bundle extends BaseBundle
  25. {
  26. /**
  27. * Customizes the Container instance.
  28. *
  29. * @param Symfony\Components\DependencyInjection\ContainerInterface $container A ContainerInterface instance
  30. *
  31. * @return Symfony\Components\DependencyInjection\BuilderConfiguration A BuilderConfiguration instance
  32. */
  33. public function buildContainer(ContainerInterface $container)
  34. {
  35. Loader::registerExtension(new WebExtension());
  36. $dirs = array('%kernel.root_dir%/views/%%bundle%%/%%controller%%/%%name%%%%format%%.%%renderer%%');
  37. foreach ($container->getParameter('kernel.bundle_dirs') as $dir) {
  38. $dirs[] = $dir.'/%%bundle%%/Resources/views/%%controller%%/%%name%%%%format%%.%%renderer%%';
  39. }
  40. $container->setParameter('templating.loader.filesystem.path', $dirs);
  41. $configuration = new BuilderConfiguration();
  42. if ($container->getParameter('kernel.debug')) {
  43. $loader = new XmlFileLoader(__DIR__.'/Resources/config');
  44. $configuration->merge($loader->load('debug.xml'));
  45. }
  46. return $configuration;
  47. }
  48. }