Configuration.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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_groups')
  65. ->useAttributeAsKey('id')
  66. ->prototype('array')
  67. ->fixXmlConfig('item')
  68. ->fixXmlConfig('item_add')
  69. ->children()
  70. ->scalarNode('label')->end()
  71. ->arrayNode('items')
  72. ->prototype('scalar')->end()
  73. ->end()
  74. ->arrayNode('item_adds')
  75. ->prototype('scalar')->end()
  76. ->end()
  77. ->end()
  78. ->end()
  79. ->end()
  80. ->arrayNode('admin_services')
  81. ->useAttributeAsKey('id')
  82. ->prototype('array')
  83. ->children()
  84. ->scalarNode('model_manager')->end()
  85. ->scalarNode('form_contractor')->end()
  86. ->scalarNode('show_builder')->end()
  87. ->scalarNode('list_builder')->end()
  88. ->scalarNode('datagrid_builder')->end()
  89. ->scalarNode('translator')->end()
  90. ->scalarNode('configuration_pool')->end()
  91. ->scalarNode('router')->end()
  92. ->scalarNode('validator')->end()
  93. ->scalarNode('security_handler')->end()
  94. ->scalarNode('label')->end()
  95. ->end()
  96. ->end()
  97. ->end()
  98. ->arrayNode('templates')
  99. ->addDefaultsIfNotSet()
  100. ->children()
  101. ->scalarNode('user_block')->defaultValue('SonataAdminBundle:Core:user_block.html.twig')->cannotBeEmpty()->end()
  102. ->scalarNode('layout')->defaultValue('SonataAdminBundle::standard_layout.html.twig')->cannotBeEmpty()->end()
  103. ->scalarNode('ajax')->defaultValue('SonataAdminBundle::ajax_layout.html.twig')->cannotBeEmpty()->end()
  104. ->scalarNode('dashboard')->defaultValue('SonataAdminBundle:Core:dashboard.html.twig')->cannotBeEmpty()->end()
  105. ->scalarNode('list')->defaultValue('SonataAdminBundle:CRUD:list.html.twig')->cannotBeEmpty()->end()
  106. ->scalarNode('show')->defaultValue('SonataAdminBundle:CRUD:show.html.twig')->cannotBeEmpty()->end()
  107. ->scalarNode('edit')->defaultValue('SonataAdminBundle:CRUD:edit.html.twig')->cannotBeEmpty()->end()
  108. ->scalarNode('history')->defaultValue('SonataAdminBundle:CRUD:history.html.twig')->cannotBeEmpty()->end()
  109. ->scalarNode('history_revision')->defaultValue('SonataAdminBundle:CRUD:history_revision.html.twig')->cannotBeEmpty()->end()
  110. ->scalarNode('action')->defaultValue('SonataAdminBundle:CRUD:action.html.twig')->cannotBeEmpty()->end()
  111. ->end()
  112. ->end()
  113. ->end()
  114. ->end();
  115. return $treeBuilder;
  116. }
  117. }