Configuration.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. ->scalarNode('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. ->scalarNode('port')
  68. ->defaultValue("4730")
  69. ->end()
  70. ->end()
  71. ->end()
  72. ->end()
  73. ->arrayNode('defaults')
  74. ->addDefaultsIfNotSet()
  75. ->children()
  76. ->scalarNode('iterations')
  77. ->defaultValue(0)
  78. ->end()
  79. ->scalarNode('method')
  80. ->defaultValue('doNormal')
  81. ->end()
  82. ->scalarNode('callbacks')
  83. ->defaultTrue()
  84. ->end()
  85. ->scalarNode('job_prefix')
  86. ->defaultNull()
  87. ->end()
  88. ->scalarNode('generate_unique_key')
  89. ->defaultTrue()
  90. ->end()
  91. ->scalarNode('workers_name_prepend_namespace')
  92. ->defaultTrue()
  93. ->end()
  94. ->end()
  95. ->end()
  96. ->end();
  97. return $treeBuilder;
  98. }
  99. }