ExampleConfiguration.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  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 Symfony\Component\Config\Tests\Fixtures\Configuration;
  11. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  12. use Symfony\Component\Config\Definition\ConfigurationInterface;
  13. class ExampleConfiguration implements ConfigurationInterface
  14. {
  15. public function getConfigTreeBuilder()
  16. {
  17. $treeBuilder = new TreeBuilder();
  18. $rootNode = $treeBuilder->root('acme_root');
  19. $rootNode
  20. ->fixXmlConfig('parameter')
  21. ->fixXmlConfig('connection')
  22. ->children()
  23. ->booleanNode('boolean')->defaultTrue()->end()
  24. ->scalarNode('scalar_empty')->end()
  25. ->scalarNode('scalar_null')->defaultNull()->end()
  26. ->scalarNode('scalar_true')->defaultTrue()->end()
  27. ->scalarNode('scalar_false')->defaultFalse()->end()
  28. ->scalarNode('scalar_default')->defaultValue('default')->end()
  29. ->scalarNode('scalar_array_empty')->defaultValue(array())->end()
  30. ->scalarNode('scalar_array_defaults')->defaultValue(array('elem1', 'elem2'))->end()
  31. ->scalarNode('scalar_required')->isRequired()->end()
  32. ->scalarNode('node_with_a_looong_name')->end()
  33. ->enumNode('enum_with_default')->values(array('this', 'that'))->defaultValue('this')->end()
  34. ->enumNode('enum')->values(array('this', 'that'))->end()
  35. ->arrayNode('array')
  36. ->info('some info')
  37. ->canBeUnset()
  38. ->children()
  39. ->scalarNode('child1')->end()
  40. ->scalarNode('child2')->end()
  41. ->scalarNode('child3')
  42. ->info(
  43. "this is a long\n".
  44. "multi-line info text\n".
  45. 'which should be indented'
  46. )
  47. ->example('example setting')
  48. ->end()
  49. ->end()
  50. ->end()
  51. ->arrayNode('parameters')
  52. ->useAttributeAsKey('name')
  53. ->prototype('scalar')->info('Parameter name')->end()
  54. ->end()
  55. ->arrayNode('connections')
  56. ->prototype('array')
  57. ->children()
  58. ->scalarNode('user')->end()
  59. ->scalarNode('pass')->end()
  60. ->end()
  61. ->end()
  62. ->end()
  63. ->end()
  64. ;
  65. return $treeBuilder;
  66. }
  67. }