Configuration.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. ->arrayNode('security')
  38. ->addDefaultsIfNotSet()
  39. ->children()
  40. ->scalarNode('handler')->defaultValue('sonata.admin.security.handler.noop')->end()
  41. ->arrayNode('information')
  42. ->useAttributeAsKey('id')
  43. ->prototype('array')
  44. ->performNoDeepMerging()
  45. ->beforeNormalization()
  46. ->ifString()
  47. ->then(function($v){ return array($v); })
  48. ->end()
  49. ->prototype('scalar')->end()
  50. ->end()
  51. ->end()
  52. ->arrayNode('admin_permissions')
  53. ->defaultValue(array('CREATE', 'LIST', 'DELETE', 'UNDELETE', 'OPERATOR', 'MASTER'))
  54. ->prototype('scalar')->end()
  55. ->end()
  56. ->arrayNode('object_permissions')
  57. ->defaultValue(array('VIEW', 'EDIT', 'DELETE', 'UNDELETE', 'OPERATOR', 'MASTER', 'OWNER'))
  58. ->prototype('scalar')->end()
  59. ->end()
  60. ->end()
  61. ->end()
  62. ->scalarNode('title')->defaultValue('Sonata Admin')->cannotBeEmpty()->end()
  63. ->scalarNode('title_logo')->defaultValue('bundles/sonataadmin/logo_title.png')->cannotBeEmpty()->end()
  64. ->arrayNode('dashboard')
  65. ->addDefaultsIfNotSet()
  66. ->children()
  67. ->arrayNode('groups')
  68. ->useAttributeAsKey('id')
  69. ->prototype('array')
  70. ->fixXmlConfig('item')
  71. ->fixXmlConfig('item_add')
  72. ->children()
  73. ->scalarNode('label')->end()
  74. ->arrayNode('items')
  75. ->prototype('scalar')->end()
  76. ->end()
  77. ->arrayNode('item_adds')
  78. ->prototype('scalar')->end()
  79. ->end()
  80. ->end()
  81. ->end()
  82. ->end()
  83. ->arrayNode('blocks')
  84. ->defaultValue(array(array('position' => 'left', 'settings' => array(), 'type' => 'sonata.admin.block.admin_list')))
  85. ->prototype('array')
  86. ->children()
  87. ->scalarNode('type')->cannotBeEmpty()->end()
  88. ->arrayNode('settings')
  89. ->useAttributeAsKey('id')
  90. ->prototype('variable')->defaultValue(array())->end()
  91. ->end()
  92. ->scalarNode('position')->defaultValue('right')->end()
  93. ->end()
  94. ->end()
  95. ->end()
  96. ->end()
  97. ->end()
  98. ->arrayNode('admin_services')
  99. ->useAttributeAsKey('id')
  100. ->prototype('array')
  101. ->children()
  102. ->scalarNode('model_manager')->end()
  103. ->scalarNode('form_contractor')->end()
  104. ->scalarNode('show_builder')->end()
  105. ->scalarNode('list_builder')->end()
  106. ->scalarNode('datagrid_builder')->end()
  107. ->scalarNode('translator')->end()
  108. ->scalarNode('configuration_pool')->end()
  109. ->scalarNode('router')->end()
  110. ->scalarNode('validator')->end()
  111. ->scalarNode('security_handler')->end()
  112. ->scalarNode('label')->end()
  113. ->end()
  114. ->end()
  115. ->end()
  116. ->arrayNode('templates')
  117. ->addDefaultsIfNotSet()
  118. ->children()
  119. ->scalarNode('user_block')->defaultValue('SonataAdminBundle:Core:user_block.html.twig')->cannotBeEmpty()->end()
  120. ->scalarNode('layout')->defaultValue('SonataAdminBundle::standard_layout.html.twig')->cannotBeEmpty()->end()
  121. ->scalarNode('ajax')->defaultValue('SonataAdminBundle::ajax_layout.html.twig')->cannotBeEmpty()->end()
  122. ->scalarNode('dashboard')->defaultValue('SonataAdminBundle:Core:dashboard.html.twig')->cannotBeEmpty()->end()
  123. ->scalarNode('list')->defaultValue('SonataAdminBundle:CRUD:list.html.twig')->cannotBeEmpty()->end()
  124. ->scalarNode('show')->defaultValue('SonataAdminBundle:CRUD:show.html.twig')->cannotBeEmpty()->end()
  125. ->scalarNode('edit')->defaultValue('SonataAdminBundle:CRUD:edit.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('short_object_description')->defaultValue('SonataAdminBundle:Helper:short-object-description.html.twig')->cannotBeEmpty()->end()
  130. ->end()
  131. ->end()
  132. ->end()
  133. ->end();
  134. return $treeBuilder;
  135. }
  136. }