Configuration.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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('dashboard_groups')
  42. ->useAttributeAsKey('id')
  43. ->prototype('array')
  44. ->children()
  45. ->scalarNode('label')->end()
  46. ->arrayNode('items')
  47. ->prototype('scalar')->end()
  48. ->end()
  49. ->arrayNode('item_adds')
  50. ->prototype('scalar')->end()
  51. ->end()
  52. ->end()
  53. ->end()
  54. ->end()
  55. ->arrayNode('admin_services')
  56. ->useAttributeAsKey('id')
  57. ->prototype('array')
  58. ->children()
  59. ->scalarNode('id')->end()
  60. ->scalarNode('model_manager')->end()
  61. ->scalarNode('form_contractor')->end()
  62. ->scalarNode('show_builder')->end()
  63. ->scalarNode('list_builder')->end()
  64. ->scalarNode('datagrid_builder')->end()
  65. ->scalarNode('translator')->end()
  66. ->scalarNode('configuration_pool')->end()
  67. ->scalarNode('router')->end()
  68. ->scalarNode('validator')->end()
  69. ->scalarNode('security_handler')->end()
  70. ->scalarNode('label')->end()
  71. ->end()
  72. ->end()
  73. ->end()
  74. ->arrayNode('templates')
  75. ->children()
  76. ->scalarNode('layout')->cannotBeEmpty()->end()
  77. ->scalarNode('ajax')->cannotBeEmpty()->end()
  78. ->end()
  79. ->end()
  80. ->end()
  81. ->end();
  82. }
  83. }