Configuration.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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\ConfigurationInterface;
  13. /**
  14. * This class contains the configuration information for the bundle
  15. *
  16. * This information is solely responsible for how the different configuration
  17. * sections are normalized, and merged.
  18. *
  19. * @author Michael Williams <mtotheikle@gmail.com>
  20. */
  21. class Configuration implements ConfigurationInterface
  22. {
  23. /**
  24. * Generates the configuration tree.
  25. *
  26. * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
  27. */
  28. public function getConfigTreeBuilder()
  29. {
  30. $treeBuilder = new TreeBuilder();
  31. $rootNode = $treeBuilder->root('sonata_admin', 'array');
  32. $rootNode
  33. ->fixXmlConfig('dashboard_group')
  34. ->fixXmlConfig('admin_service')
  35. ->children()
  36. ->arrayNode('security')
  37. ->addDefaultsIfNotSet()
  38. ->children()
  39. ->scalarNode('handler')->defaultValue('sonata.admin.security.handler.noop')->end()
  40. ->arrayNode('information')
  41. ->useAttributeAsKey('id')
  42. ->prototype('array')
  43. ->performNoDeepMerging()
  44. ->beforeNormalization()
  45. ->ifString()
  46. ->then(function($v){ return array($v); })
  47. ->end()
  48. ->prototype('scalar')->end()
  49. ->end()
  50. ->end()
  51. ->arrayNode('admin_permissions')
  52. ->defaultValue(array('CREATE', 'LIST', 'DELETE', 'UNDELETE', 'EXPORT', 'OPERATOR', 'MASTER'))
  53. ->prototype('scalar')->end()
  54. ->end()
  55. ->arrayNode('object_permissions')
  56. ->defaultValue(array('VIEW', 'EDIT', 'DELETE', 'UNDELETE', 'OPERATOR', 'MASTER', 'OWNER'))
  57. ->prototype('scalar')->end()
  58. ->end()
  59. ->end()
  60. ->end()
  61. ->scalarNode('title')->defaultValue('Sonata Admin')->cannotBeEmpty()->end()
  62. ->scalarNode('title_logo')->defaultValue('bundles/sonataadmin/logo_title.png')->cannotBeEmpty()->end()
  63. ->arrayNode('dashboard')
  64. ->addDefaultsIfNotSet()
  65. ->children()
  66. ->arrayNode('groups')
  67. ->useAttributeAsKey('id')
  68. ->prototype('array')
  69. ->fixXmlConfig('item')
  70. ->fixXmlConfig('item_add')
  71. ->children()
  72. ->scalarNode('label')->end()
  73. ->arrayNode('items')
  74. ->prototype('scalar')->end()
  75. ->end()
  76. ->arrayNode('item_adds')
  77. ->prototype('scalar')->end()
  78. ->end()
  79. ->end()
  80. ->end()
  81. ->end()
  82. ->arrayNode('blocks')
  83. ->defaultValue(array(array('position' => 'left', 'settings' => array(), 'type' => 'sonata.admin.block.admin_list')))
  84. ->prototype('array')
  85. ->children()
  86. ->scalarNode('type')->cannotBeEmpty()->end()
  87. ->arrayNode('settings')
  88. ->useAttributeAsKey('id')
  89. ->prototype('variable')->defaultValue(array())->end()
  90. ->end()
  91. ->scalarNode('position')->defaultValue('right')->end()
  92. ->end()
  93. ->end()
  94. ->end()
  95. ->end()
  96. ->end()
  97. ->arrayNode('admin_services')
  98. ->useAttributeAsKey('id')
  99. ->prototype('array')
  100. ->children()
  101. ->scalarNode('model_manager')->end()
  102. ->scalarNode('form_contractor')->end()
  103. ->scalarNode('show_builder')->end()
  104. ->scalarNode('list_builder')->end()
  105. ->scalarNode('datagrid_builder')->end()
  106. ->scalarNode('translator')->end()
  107. ->scalarNode('configuration_pool')->end()
  108. ->scalarNode('router')->end()
  109. ->scalarNode('validator')->end()
  110. ->scalarNode('security_handler')->end()
  111. ->scalarNode('label')->end()
  112. ->end()
  113. ->end()
  114. ->end()
  115. ->arrayNode('templates')
  116. ->addDefaultsIfNotSet()
  117. ->children()
  118. ->scalarNode('user_block')->defaultValue('SonataAdminBundle:Core:user_block.html.twig')->cannotBeEmpty()->end()
  119. ->scalarNode('layout')->defaultValue('SonataAdminBundle::standard_layout.html.twig')->cannotBeEmpty()->end()
  120. ->scalarNode('ajax')->defaultValue('SonataAdminBundle::ajax_layout.html.twig')->cannotBeEmpty()->end()
  121. ->scalarNode('dashboard')->defaultValue('SonataAdminBundle:Core:dashboard.html.twig')->cannotBeEmpty()->end()
  122. ->scalarNode('list')->defaultValue('SonataAdminBundle:CRUD:list.html.twig')->cannotBeEmpty()->end()
  123. ->scalarNode('show')->defaultValue('SonataAdminBundle:CRUD:show.html.twig')->cannotBeEmpty()->end()
  124. ->scalarNode('edit')->defaultValue('SonataAdminBundle:CRUD:edit.html.twig')->cannotBeEmpty()->end()
  125. ->scalarNode('preview')->defaultValue('SonataAdminBundle:CRUD:preview.html.twig')->cannotBeEmpty()->end()
  126. ->scalarNode('history')->defaultValue('SonataAdminBundle:CRUD:history.html.twig')->cannotBeEmpty()->end()
  127. ->scalarNode('history_revision')->defaultValue('SonataAdminBundle:CRUD:history_revision.html.twig')->cannotBeEmpty()->end()
  128. ->scalarNode('action')->defaultValue('SonataAdminBundle:CRUD:action.html.twig')->cannotBeEmpty()->end()
  129. ->scalarNode('list_block')->defaultValue('SonataAdminBundle:Block:block_admin_list.html.twig')->cannotBeEmpty()->end()
  130. ->scalarNode('short_object_description')->defaultValue('SonataAdminBundle:Helper:short-object-description.html.twig')->cannotBeEmpty()->end()
  131. ->scalarNode('delete')->defaultValue('SonataAdminBundle:CRUD:delete.html.twig')->cannotBeEmpty()->end()
  132. ->scalarNode('batch')->defaultValue('SonataAdminBundle:CRUD:list__batch.html.twig')->cannotBeEmpty()->end()
  133. ->end()
  134. ->end()
  135. ->scalarNode('persist_filters')->defaultValue(false)->cannotBeEmpty()->end()
  136. ->end()
  137. ->end();
  138. return $treeBuilder;
  139. }
  140. }