Configuration.php 3.9 KB

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