1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SfCod\QueueBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
6
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
7
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
8
|
|
|
use Symfony\Component\HttpKernel\Kernel; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class QueueConfiguration |
12
|
|
|
* |
13
|
|
|
* @author Virchenko Maksim <[email protected]> |
14
|
|
|
* |
15
|
|
|
* @package SfCod\QueueBundle\DependencyInjection |
16
|
|
|
*/ |
17
|
|
|
class QueueConfiguration implements ConfigurationInterface |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Generates the configuration tree builder. |
21
|
|
|
* |
22
|
|
|
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder |
23
|
|
|
*/ |
24
|
|
|
public function getConfigTreeBuilder() |
25
|
|
|
{ |
26
|
|
|
if (Kernel::VERSION_ID >= 40300) { |
27
|
|
|
$treeBuilder = new TreeBuilder('sfcod_queue'); |
28
|
|
|
$rootNode = $treeBuilder->getRootNode(); |
29
|
|
|
} else { |
30
|
|
|
$treeBuilder = new TreeBuilder(); |
|
|
|
|
31
|
|
|
$rootNode = $treeBuilder->root('sfcod_queue'); |
|
|
|
|
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
$this->addConnections($rootNode); |
35
|
|
|
|
36
|
|
|
return $treeBuilder; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Add connections config |
41
|
|
|
* |
42
|
|
|
* @param ArrayNodeDefinition $rootNode |
43
|
|
|
*/ |
44
|
|
|
private function addConnections(ArrayNodeDefinition $rootNode) |
45
|
|
|
{ |
46
|
|
|
$rootNode |
47
|
|
|
->children() |
48
|
|
|
->arrayNode('namespaces') |
49
|
|
|
->scalarPrototype()->end() |
50
|
|
|
->end() |
51
|
|
|
->end() |
52
|
|
|
->children() |
53
|
|
|
->arrayNode('drivers') |
54
|
|
|
->useAttributeAsKey('name') |
55
|
|
|
->scalarPrototype()->end() |
56
|
|
|
->end() |
57
|
|
|
->end() |
58
|
|
|
->children() |
59
|
|
|
->arrayNode('connections') |
60
|
|
|
->useAttributeAsKey('name') |
61
|
|
|
->arrayPrototype() |
62
|
|
|
->children() |
63
|
|
|
->scalarNode('driver')->end() |
64
|
|
|
->scalarNode('collection')->end() |
65
|
|
|
->scalarNode('connection')->end() |
66
|
|
|
->scalarNode('queue')->end() |
67
|
|
|
->scalarNode('expire')->end() |
68
|
|
|
->scalarNode('limit')->end() |
69
|
|
|
->end() |
70
|
|
|
->end() |
71
|
|
|
->end() |
72
|
|
|
->end(); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
This check looks for function calls that miss required arguments.