Configuration.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace Mmoreram\GearmanBundle\DependencyInjection;
  3. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  4. use Symfony\Component\Config\Definition\ConfigurationInterface;
  5. /**
  6. * This is the class that validates and merges configuration from your app/config files
  7. *
  8. * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
  9. */
  10. class Configuration implements ConfigurationInterface
  11. {
  12. /**
  13. * Generates the configuration tree builder.
  14. *
  15. * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
  16. */
  17. public function getConfigTreeBuilder()
  18. {
  19. $treeBuilder = new TreeBuilder();
  20. $rootNode = $treeBuilder->root('gearman');
  21. $rootNode
  22. ->children()
  23. ->arrayNode('bundles')
  24. ->prototype('array')
  25. ->children()
  26. ->scalarNode('namespace')
  27. ->isRequired()
  28. ->cannotBeEmpty()
  29. ->end()
  30. ->scalarNode('active')
  31. ->defaultFalse()
  32. ->end()
  33. ->arrayNode('include')
  34. ->prototype('scalar')->end()
  35. ->end()
  36. ->arrayNode('ignore')
  37. ->prototype('scalar')->end()
  38. ->end()
  39. ->end()
  40. ->end()
  41. ->end()
  42. ->arrayNode('servers')
  43. ->defaultValue(array(
  44. 'localhost' => array(
  45. 'hostname' => '127.0.0.1',
  46. 'port' => 4730,
  47. )
  48. ))
  49. ->prototype('array')
  50. ->children()
  51. ->scalarNode('hostname')
  52. ->isRequired()
  53. ->cannotBeEmpty()
  54. ->end()
  55. ->scalarNode('port')
  56. ->defaultValue(4730)
  57. ->end()
  58. ->end()
  59. ->end()
  60. ->end()
  61. ->arrayNode('defaults')
  62. ->children()
  63. ->scalarNode('iterations')
  64. ->defaultValue(150)
  65. ->end()
  66. ->scalarNode('method')
  67. ->defaultValue('do')
  68. ->end()
  69. ->end()
  70. ->end()
  71. ->end()
  72. ;
  73. return $treeBuilder;
  74. }
  75. }