Configuration.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /*
  3. * This file is part of the Sonata project.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  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 Sonata\AdminBundle\DependencyInjection;
  11. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  12. use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
  13. use Symfony\Component\Config\Definition\ConfigurationInterface;
  14. /**
  15. * This class contains the configuration information for the bundle
  16. *
  17. * This information is solely responsible for how the different configuration
  18. * sections are normalized, and merged.
  19. *
  20. * @author Michael Williams <mtotheikle@gmail.com>
  21. */
  22. class Configuration implements ConfigurationInterface
  23. {
  24. /**
  25. * Generates the configuration tree.
  26. *
  27. * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
  28. */
  29. public function getConfigTreeBuilder()
  30. {
  31. $treeBuilder = new TreeBuilder();
  32. $rootNode = $treeBuilder->root('sonata_admin', 'array');
  33. $this->addTemplateSection($rootNode);
  34. return $treeBuilder;
  35. }
  36. private function addTemplateSection(ArrayNodeDefinition $rootNode)
  37. {
  38. $rootNode
  39. ->children()
  40. ->scalarNode('security_handler')->defaultValue('sonata.admin.security.handler.noop')->end()
  41. ->arrayNode('templates')
  42. ->children()
  43. ->scalarNode('layout')->cannotBeEmpty()->end()
  44. ->scalarNode('ajax')->cannotBeEmpty()->end()
  45. ->end()
  46. ->end()
  47. ->end()
  48. ->end();
  49. }
  50. }