Configuration.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /**
  3. * Gearman Bundle for Symfony2
  4. *
  5. * @author Marc Morera <yuhu@mmoreram.com>
  6. * @since 2013
  7. */
  8. namespace Mmoreram\GearmanBundle\DependencyInjection;
  9. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  10. use Symfony\Component\Config\Definition\ConfigurationInterface;
  11. /**
  12. * This is the class that validates and merges configuration from your app/config files
  13. */
  14. class Configuration implements ConfigurationInterface
  15. {
  16. /**
  17. * Generates the configuration tree builder.
  18. *
  19. * @return TreeBuilder The tree builder
  20. */
  21. public function getConfigTreeBuilder()
  22. {
  23. $treeBuilder = new TreeBuilder();
  24. $rootNode = $treeBuilder->root('gearman');
  25. $rootNode
  26. ->children()
  27. ->arrayNode('bundles')
  28. ->prototype('array')
  29. ->children()
  30. ->scalarNode('name')
  31. ->isRequired()
  32. ->cannotBeEmpty()
  33. ->end()
  34. ->scalarNode('active')
  35. ->defaultFalse()
  36. ->end()
  37. ->arrayNode('include')
  38. ->prototype('scalar')->end()
  39. ->end()
  40. ->arrayNode('ignore')
  41. ->prototype('scalar')->end()
  42. ->end()
  43. ->end()
  44. ->end()
  45. ->end()
  46. ->arrayNode('servers')
  47. ->performNoDeepMerging()
  48. ->defaultValue(array(
  49. 'localhost' => array(
  50. 'host' => '127.0.0.1',
  51. 'port' => "4730",
  52. )
  53. ))
  54. ->prototype('array')
  55. ->children()
  56. ->scalarNode('host')
  57. ->isRequired()
  58. ->cannotBeEmpty()
  59. ->end()
  60. ->scalarNode('port')
  61. ->defaultValue("4730")
  62. ->end()
  63. ->end()
  64. ->end()
  65. ->end()
  66. ->arrayNode('defaults')
  67. ->addDefaultsIfNotSet()
  68. ->children()
  69. ->scalarNode('iterations')
  70. ->defaultValue(0)
  71. ->end()
  72. ->scalarNode('method')
  73. ->defaultValue('doNormal')
  74. ->end()
  75. ->scalarNode('callbacks')
  76. ->defaultTrue()
  77. ->end()
  78. ->scalarNode('job_prefix')
  79. ->defaultNull()
  80. ->end()
  81. ->scalarNode('generate_unique_key')
  82. ->defaultTrue()
  83. ->end()
  84. ->scalarNode('workers_name_prepend_namespace')
  85. ->defaultTrue()
  86. ->end()
  87. ->end()
  88. ->end()
  89. ->end();
  90. return $treeBuilder;
  91. }
  92. }