Configuration.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. ->scalarNode('title')->defaultValue('Sonata > ')->cannotBeEmpty()->end()
  42. ->scalarNode('title_logo')->defaultValue('/bundles/sonataadmin/logo_title.png')->cannotBeEmpty()->end()
  43. ->arrayNode('dashboard_groups')
  44. ->useAttributeAsKey('id')
  45. ->prototype('array')
  46. ->children()
  47. ->scalarNode('label')->end()
  48. ->arrayNode('items')
  49. ->prototype('scalar')->end()
  50. ->end()
  51. ->arrayNode('item_adds')
  52. ->prototype('scalar')->end()
  53. ->end()
  54. ->end()
  55. ->end()
  56. ->end()
  57. ->arrayNode('admin_services')
  58. ->useAttributeAsKey('id')
  59. ->prototype('array')
  60. ->children()
  61. ->scalarNode('id')->end()
  62. ->scalarNode('model_manager')->end()
  63. ->scalarNode('form_contractor')->end()
  64. ->scalarNode('show_builder')->end()
  65. ->scalarNode('list_builder')->end()
  66. ->scalarNode('datagrid_builder')->end()
  67. ->scalarNode('translator')->end()
  68. ->scalarNode('configuration_pool')->end()
  69. ->scalarNode('router')->end()
  70. ->scalarNode('validator')->end()
  71. ->scalarNode('security_handler')->end()
  72. ->scalarNode('label')->end()
  73. ->end()
  74. ->end()
  75. ->end()
  76. ->arrayNode('templates')
  77. ->addDefaultsIfNotSet()
  78. ->children()
  79. ->scalarNode('user_block')->defaultValue('SonataAdminBundle:Core:user_block.html.twig')->cannotBeEmpty()->end()
  80. ->scalarNode('layout')->defaultValue('SonataAdminBundle::standard_layout.html.twig')->cannotBeEmpty()->end()
  81. ->scalarNode('ajax')->defaultValue('SonataAdminBundle::ajax_layout.html.twig')->cannotBeEmpty()->end()
  82. ->scalarNode('list')->defaultValue('SonataAdminBundle:CRUD:list.html.twig')->cannotBeEmpty()->end()
  83. ->scalarNode('show')->defaultValue('SonataAdminBundle:CRUD:show.html.twig')->cannotBeEmpty()->end()
  84. ->scalarNode('edit')->defaultValue('SonataAdminBundle:CRUD:edit.html.twig')->cannotBeEmpty()->end()
  85. ->end()
  86. ->end()
  87. ->end()
  88. ->end();
  89. }
  90. }