Configuration.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. $rootNode
  34. ->fixXmlConfig('dashboard_group')
  35. ->fixXmlConfig('admin_service')
  36. ->children()
  37. ->scalarNode('security_handler')->defaultValue('sonata.admin.security.handler.noop')->end()
  38. ->scalarNode('title')->defaultValue('Sonata Admin')->cannotBeEmpty()->end()
  39. ->scalarNode('title_logo')->defaultValue('bundles/sonataadmin/logo_title.png')->cannotBeEmpty()->end()
  40. ->arrayNode('dashboard_groups')
  41. ->useAttributeAsKey('id')
  42. ->prototype('array')
  43. ->fixXmlConfig('item')
  44. ->fixXmlConfig('item_add')
  45. ->children()
  46. ->scalarNode('label')->end()
  47. ->arrayNode('items')
  48. ->prototype('scalar')->end()
  49. ->end()
  50. ->arrayNode('item_adds')
  51. ->prototype('scalar')->end()
  52. ->end()
  53. ->end()
  54. ->end()
  55. ->end()
  56. ->arrayNode('admin_services')
  57. ->useAttributeAsKey('id')
  58. ->prototype('array')
  59. ->children()
  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. ->addDefaultsIfNotSet()
  76. ->children()
  77. ->scalarNode('user_block')->defaultValue('SonataAdminBundle:Core:user_block.html.twig')->cannotBeEmpty()->end()
  78. ->scalarNode('layout')->defaultValue('SonataAdminBundle::standard_layout.html.twig')->cannotBeEmpty()->end()
  79. ->scalarNode('ajax')->defaultValue('SonataAdminBundle::ajax_layout.html.twig')->cannotBeEmpty()->end()
  80. ->scalarNode('list')->defaultValue('SonataAdminBundle:CRUD:list.html.twig')->cannotBeEmpty()->end()
  81. ->scalarNode('show')->defaultValue('SonataAdminBundle:CRUD:show.html.twig')->cannotBeEmpty()->end()
  82. ->scalarNode('edit')->defaultValue('SonataAdminBundle:CRUD:edit.html.twig')->cannotBeEmpty()->end()
  83. ->scalarNode('history')->defaultValue('SonataAdminBundle:CRUD:history.html.twig')->cannotBeEmpty()->end()
  84. ->scalarNode('history_revision')->defaultValue('SonataAdminBundle:CRUD:history_revision.html.twig')->cannotBeEmpty()->end()
  85. ->scalarNode('action')->defaultValue('SonataAdminBundle:CRUD:action.html.twig')->cannotBeEmpty()->end()
  86. ->end()
  87. ->end()
  88. ->end()
  89. ->end();
  90. return $treeBuilder;
  91. }
  92. }