Configuration.php 993 B

12345678910111213141516171819202122232425262728293031323334353637
  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\Definition\Builder\TreeBuilder;
  12. use Symfony\Component\Config\Definition\ConfigurationInterface;
  13. use Twig\Extra\TwigExtraBundle\Extensions;
  14. class Configuration implements ConfigurationInterface
  15. {
  16. public function getConfigTreeBuilder()
  17. {
  18. $treeBuilder = new TreeBuilder('twig_extra');
  19. $rootNode = $treeBuilder->getRootNode();
  20. foreach (Extensions::getClasses() as $name => $class) {
  21. $rootNode
  22. ->children()
  23. ->arrayNode($name)
  24. ->{class_exists($class) ? 'canBeDisabled' : 'canBeEnabled'}()
  25. ->end()
  26. ->end()
  27. ;
  28. }
  29. return $treeBuilder;
  30. }
  31. }