1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kaliop\Queueing\Plugins\StompBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
6
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
7
|
|
|
use \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
8
|
|
|
|
9
|
|
|
class Configuration implements ConfigurationInterface |
10
|
|
|
{ |
11
|
|
|
public function getConfigTreeBuilder() |
12
|
|
|
{ |
13
|
|
|
$tree = new TreeBuilder(); |
14
|
|
|
|
15
|
|
|
$rootNode = $tree->root('kaliop_queueing_plugins_stomp'); |
|
|
|
|
16
|
|
|
|
17
|
|
|
$this->addConnections($rootNode); |
18
|
|
|
$this->addProducers($rootNode); |
19
|
|
|
$this->addConsumers($rootNode); |
20
|
|
|
|
21
|
|
|
return $tree; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
protected function addConnections(ArrayNodeDefinition $node) |
25
|
|
|
{ |
26
|
|
|
$node |
27
|
|
|
->fixXmlConfig('connection') |
28
|
|
|
->children() |
29
|
|
|
->arrayNode('connections') |
30
|
|
|
->useAttributeAsKey('key') |
31
|
|
|
->canBeUnset() |
32
|
|
|
->prototype('array') |
33
|
|
|
->children() |
34
|
|
|
->scalarNode('connect_string')->isRequired()->end() |
35
|
|
|
->variableNode('credentials') |
36
|
|
|
/// @todo: validate presence of user, password |
37
|
|
|
//->children() |
38
|
|
|
//->whatever... |
39
|
|
|
//->end() |
40
|
|
|
->end() |
41
|
|
|
->booleanNode('debug')->defaultFalse()->end() |
42
|
|
|
//->variableNode('http') |
43
|
|
|
//->children() |
44
|
|
|
//->whatever... |
45
|
|
|
//->end() |
46
|
|
|
//->end() |
47
|
|
|
->end() |
48
|
|
|
->end() |
49
|
|
|
->end() |
50
|
|
|
->end() |
51
|
|
|
; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
protected function addProducers(ArrayNodeDefinition $node) |
55
|
|
|
{ |
56
|
|
|
$node |
57
|
|
|
->fixXmlConfig('producer') |
58
|
|
|
->children() |
59
|
|
|
->arrayNode('producers') |
60
|
|
|
->canBeUnset() |
61
|
|
|
->useAttributeAsKey('key') |
62
|
|
|
->prototype('array') |
63
|
|
|
->append($this->getQueueConfiguration()) |
64
|
|
|
->children() |
65
|
|
|
->scalarNode('connection')->defaultValue('default')->end() |
66
|
|
|
//->scalarNode('auto_setup_fabric')->defaultTrue()->end() |
67
|
|
|
->end() |
68
|
|
|
->end() |
69
|
|
|
->end() |
70
|
|
|
->end() |
71
|
|
|
; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
protected function addConsumers(ArrayNodeDefinition $node) |
75
|
|
|
{ |
76
|
|
|
$node |
77
|
|
|
->fixXmlConfig('consumer') |
78
|
|
|
->children() |
79
|
|
|
->arrayNode('consumers') |
80
|
|
|
->canBeUnset() |
81
|
|
|
->useAttributeAsKey('key') |
82
|
|
|
->prototype('array') |
83
|
|
|
->append($this->getQueueConfiguration()) |
84
|
|
|
->append($this->getSubscriptionConfiguration()) |
85
|
|
|
->children() |
86
|
|
|
->scalarNode('connection')->defaultValue('default')->end() |
87
|
|
|
->scalarNode('callback')->isRequired()->end() // Q: could it be made optional? |
88
|
|
|
//->scalarNode('auto_setup_fabric')->defaultTrue()->end() |
89
|
|
|
->end() |
90
|
|
|
->end() |
91
|
|
|
->end() |
92
|
|
|
->end() |
93
|
|
|
; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
protected function getQueueConfiguration() |
97
|
|
|
{ |
98
|
|
|
$node = new ArrayNodeDefinition('queue_options'); |
99
|
|
|
|
100
|
|
|
return $node |
101
|
|
|
->children() |
102
|
|
|
->scalarNode('name')->isRequired()->end() |
103
|
|
|
->end() |
104
|
|
|
; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
protected function getSubscriptionConfiguration() |
108
|
|
|
{ |
109
|
|
|
$node = new ArrayNodeDefinition('subscription_options'); |
110
|
|
|
|
111
|
|
|
$this->addSubscriptionNodeConfiguration($node); |
112
|
|
|
|
113
|
|
|
return $node; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @todo we use an array for routing keys, as RabbitMQ config does, but we probably only support one |
118
|
|
|
* @param ArrayNodeDefinition $node |
119
|
|
|
*/ |
120
|
|
|
protected function addSubscriptionNodeConfiguration(ArrayNodeDefinition $node) |
121
|
|
|
{ |
122
|
|
|
$node |
123
|
|
|
->children() |
124
|
|
|
->scalarNode('name')->isRequired()->end() |
125
|
|
|
->arrayNode('routing_keys') |
126
|
|
|
->prototype('scalar')->end() |
127
|
|
|
->defaultValue(array()) |
128
|
|
|
->end() |
129
|
|
|
->end() |
130
|
|
|
; |
131
|
|
|
} |
132
|
|
|
} |
133
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.