Configuration.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
  15. */
  16. class Configuration implements ConfigurationInterface
  17. {
  18. /**
  19. * Generates the configuration tree builder.
  20. *
  21. * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
  22. */
  23. public function getConfigTreeBuilder()
  24. {
  25. $treeBuilder = new TreeBuilder();
  26. $rootNode = $treeBuilder->root('gearman');
  27. $rootNode
  28. ->children()
  29. ->arrayNode('bundles')
  30. ->prototype('array')
  31. ->children()
  32. ->scalarNode('name')
  33. ->isRequired()
  34. ->cannotBeEmpty()
  35. ->end()
  36. ->scalarNode('active')
  37. ->defaultFalse()
  38. ->end()
  39. ->arrayNode('include')
  40. ->prototype('scalar')->end()
  41. ->end()
  42. ->arrayNode('ignore')
  43. ->prototype('scalar')->end()
  44. ->end()
  45. ->end()
  46. ->end()
  47. ->end()
  48. ->arrayNode('servers')
  49. ->defaultValue(array(
  50. 'localhost' => array(
  51. 'hostname' => '127.0.0.1',
  52. 'port' => "4730",
  53. )
  54. ))
  55. ->prototype('array')
  56. ->children()
  57. ->scalarNode('host')
  58. ->isRequired()
  59. ->cannotBeEmpty()
  60. ->end()
  61. ->scalarNode('port')
  62. ->defaultValue("4730")
  63. ->end()
  64. ->end()
  65. ->end()
  66. ->end()
  67. ->arrayNode('defaults')
  68. ->children()
  69. ->scalarNode('iterations')
  70. ->defaultValue(0)
  71. ->end()
  72. ->scalarNode('method')
  73. ->defaultValue('doNormal')
  74. ->end()
  75. ->scalarNode('callbacks')
  76. ->defaultValue(true)
  77. ->end()
  78. ->scalarNode('job_prefix')
  79. ->defaultValue(null)
  80. ->end()
  81. ->scalarNode('generate-unique-key')
  82. ->defaultValue(true)
  83. ->end()
  84. ->end()
  85. ->end()
  86. ->end();
  87. return $treeBuilder;
  88. }
  89. }