TwigExtraExtension.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) Fabien Potencier
  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 Twig\Extra\TwigExtraBundle\DependencyInjection;
  11. use Symfony\Component\Config\FileLocator;
  12. use Symfony\Component\DependencyInjection\ContainerBuilder;
  13. use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
  14. use Symfony\Component\HttpKernel\DependencyInjection\Extension;
  15. use Twig\Extra\TwigExtraBundle\Extensions;
  16. /**
  17. * @author Fabien Potencier <fabien@symfony.com>
  18. */
  19. class TwigExtraExtension extends Extension
  20. {
  21. public function load(array $configs, ContainerBuilder $container)
  22. {
  23. $loader = new PhpFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config'));
  24. $configuration = $this->getConfiguration($configs, $container);
  25. $config = $this->processConfiguration($configuration, $configs);
  26. if ($container->getParameter('kernel.debug')) {
  27. $loader->load('suggestor.php');
  28. }
  29. foreach (array_keys(Extensions::getClasses()) as $extension) {
  30. if ($this->isConfigEnabled($container, $config[$extension])) {
  31. $loader->load($extension.'.php');
  32. }
  33. }
  34. }
  35. }