|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sonata Project package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Thomas Rabaix <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Sonata\CacheBundle\DependencyInjection; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
15
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* This is the class that validates and merges configuration from your app/config files. |
|
19
|
|
|
* |
|
20
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class} |
|
21
|
|
|
*/ |
|
22
|
|
|
class Configuration implements ConfigurationInterface |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* {@inheritdoc} |
|
26
|
|
|
*/ |
|
27
|
|
|
public function getConfigTreeBuilder() |
|
28
|
|
|
{ |
|
29
|
|
|
$treeBuilder = new TreeBuilder(); |
|
30
|
|
|
$node = $treeBuilder->root('sonata_cache')->children(); |
|
31
|
|
|
|
|
32
|
|
|
$node |
|
33
|
|
|
->arrayNode('cache_invalidation') |
|
34
|
|
|
->addDefaultsIfNotSet() |
|
35
|
|
|
->children() |
|
36
|
|
|
->enumNode('orm_listener') |
|
37
|
|
|
->values(array(true, false, 'auto')) |
|
38
|
|
|
->defaultValue('auto') |
|
39
|
|
|
->end() |
|
40
|
|
|
->enumNode('phpcr_odm_listener') |
|
41
|
|
|
->values(array(true, false, 'auto')) |
|
42
|
|
|
->defaultValue('auto') |
|
43
|
|
|
->end() |
|
44
|
|
|
->scalarNode('service')->defaultValue('sonata.cache.invalidation.simple')->end() |
|
45
|
|
|
->scalarNode('recorder')->defaultValue('sonata.cache.recorder')->end() |
|
46
|
|
|
->arrayNode('classes') |
|
47
|
|
|
->useAttributeAsKey('id') |
|
48
|
|
|
->prototype('scalar')->end() |
|
49
|
|
|
->end() |
|
50
|
|
|
->end() |
|
51
|
|
|
->end() |
|
52
|
|
|
|
|
53
|
|
|
->scalarNode('default_cache')->defaultValue(false)->end() |
|
54
|
|
|
->scalarNode('default_counter')->defaultValue(false)->end() |
|
55
|
|
|
|
|
56
|
|
|
->arrayNode('caches') |
|
57
|
|
|
->children() |
|
58
|
|
|
->arrayNode('esi') |
|
59
|
|
|
->children() |
|
60
|
|
|
->scalarNode('token')->defaultValue(hash('sha256', uniqid(mt_rand(), true)))->end() |
|
61
|
|
|
->scalarNode('version')->defaultValue(2)->end() |
|
62
|
|
|
->arrayNode('servers') |
|
63
|
|
|
->prototype('scalar')->end() |
|
64
|
|
|
->end() |
|
65
|
|
|
->end() |
|
66
|
|
|
->end() |
|
67
|
|
|
|
|
68
|
|
|
->arrayNode('ssi') |
|
69
|
|
|
->children() |
|
70
|
|
|
->scalarNode('token')->defaultValue(hash('sha256', uniqid(mt_rand(), true)))->end() |
|
71
|
|
|
->end() |
|
72
|
|
|
->end() |
|
73
|
|
|
|
|
74
|
|
|
->arrayNode('mongo') |
|
75
|
|
|
->children() |
|
76
|
|
|
->scalarNode('database')->isRequired()->end() |
|
77
|
|
|
->scalarNode('collection')->isRequired()->end() |
|
78
|
|
|
->arrayNode('servers') |
|
79
|
|
|
->prototype('array') |
|
80
|
|
|
->children() |
|
81
|
|
|
->integerNode('port')->defaultValue(27017)->end() |
|
82
|
|
|
->scalarNode('host')->isRequired()->end() |
|
83
|
|
|
->scalarNode('user')->defaultValue(null)->end() |
|
84
|
|
|
->scalarNode('password')->defaultValue(null)->end() |
|
85
|
|
|
->end() |
|
86
|
|
|
->end() |
|
87
|
|
|
->end() |
|
88
|
|
|
->end() |
|
89
|
|
|
->end() |
|
90
|
|
|
|
|
91
|
|
|
->arrayNode('memcached') |
|
92
|
|
|
->children() |
|
93
|
|
|
->scalarNode('prefix')->isRequired()->end() |
|
94
|
|
|
->arrayNode('servers') |
|
95
|
|
|
->prototype('array') |
|
96
|
|
|
->children() |
|
97
|
|
|
->integerNode('port')->defaultValue(11211)->end() |
|
98
|
|
|
->scalarNode('host')->defaultValue('localhost')->end() |
|
99
|
|
|
->integerNode('weight')->defaultValue(0)->end() |
|
100
|
|
|
->end() |
|
101
|
|
|
->end() |
|
102
|
|
|
->end() |
|
103
|
|
|
->end() |
|
104
|
|
|
->end() |
|
105
|
|
|
|
|
106
|
|
|
->arrayNode('predis') |
|
107
|
|
|
->children() |
|
108
|
|
|
->arrayNode('servers') |
|
109
|
|
|
->prototype('array') |
|
110
|
|
|
->children() |
|
111
|
|
|
->integerNode('port')->defaultValue(6379)->end() |
|
112
|
|
|
->scalarNode('host')->defaultValue('localhost')->end() |
|
113
|
|
|
->integerNode('database')->isRequired()->end() |
|
114
|
|
|
->end() |
|
115
|
|
|
->end() |
|
116
|
|
|
->end() |
|
117
|
|
|
->end() |
|
118
|
|
|
->end() |
|
119
|
|
|
|
|
120
|
|
|
->arrayNode('apc') |
|
121
|
|
|
->children() |
|
122
|
|
|
->scalarNode('token')->isRequired()->end() |
|
123
|
|
|
->scalarNode('prefix')->isRequired()->end() |
|
124
|
|
|
->arrayNode('servers') |
|
125
|
|
|
->prototype('array') |
|
126
|
|
|
->children() |
|
127
|
|
|
->scalarNode('domain')->isRequired()->end() |
|
128
|
|
|
->scalarNode('ip')->isRequired()->end() |
|
129
|
|
|
->integerNode('port')->defaultValue(80)->end() |
|
130
|
|
|
->scalarNode('basic')->defaultValue(false)->end() |
|
131
|
|
|
->end() |
|
132
|
|
|
->end() |
|
133
|
|
|
->end() |
|
134
|
|
|
->arrayNode('timeout') |
|
135
|
|
|
->addDefaultsIfNotSet() |
|
136
|
|
|
->children() |
|
137
|
|
|
->arrayNode('RCV') |
|
138
|
|
|
->prototype('scalar')->end() |
|
139
|
|
|
->end() |
|
140
|
|
|
->arrayNode('SND') |
|
141
|
|
|
->prototype('scalar')->end() |
|
142
|
|
|
->end() |
|
143
|
|
|
->end() |
|
144
|
|
|
->end() |
|
145
|
|
|
->end() |
|
146
|
|
|
->end() |
|
147
|
|
|
|
|
148
|
|
|
->arrayNode('symfony') |
|
149
|
|
|
->children() |
|
150
|
|
|
->scalarNode('token')->isRequired()->end() |
|
151
|
|
|
->variableNode('types') |
|
152
|
|
|
->defaultValue(array('all', 'annotations', 'doctrine', 'sonata', 'translations', 'twig')) |
|
153
|
|
|
->validate() |
|
154
|
|
|
->ifString() |
|
155
|
|
|
->thenInvalid('Symfony cache types must be an array [value1, value2, ...]') |
|
156
|
|
|
->end() |
|
157
|
|
|
->validate() |
|
158
|
|
|
->ifNull() |
|
159
|
|
|
->thenInvalid('Symfony cache types cannot be null') |
|
160
|
|
|
->end() |
|
161
|
|
|
->end() |
|
162
|
|
|
->booleanNode('php_cache_enabled')->defaultValue(false)->end() |
|
163
|
|
|
->arrayNode('servers') |
|
164
|
|
|
->prototype('array') |
|
165
|
|
|
->children() |
|
166
|
|
|
->scalarNode('domain')->isRequired()->end() |
|
167
|
|
|
->scalarNode('ip')->isRequired()->end() |
|
168
|
|
|
->integerNode('port')->defaultValue(80)->end() |
|
169
|
|
|
->scalarNode('basic')->defaultValue(false)->end() |
|
170
|
|
|
->end() |
|
171
|
|
|
->end() |
|
172
|
|
|
->end() |
|
173
|
|
|
->end() |
|
174
|
|
|
->end() |
|
175
|
|
|
->end() |
|
176
|
|
|
->end() |
|
177
|
|
|
->arrayNode('counters') |
|
178
|
|
|
->children() |
|
179
|
|
|
->arrayNode('mongo') |
|
180
|
|
|
->children() |
|
181
|
|
|
->scalarNode('database')->isRequired()->end() |
|
182
|
|
|
->scalarNode('collection')->isRequired()->end() |
|
183
|
|
|
->arrayNode('servers') |
|
184
|
|
|
->prototype('array') |
|
185
|
|
|
->children() |
|
186
|
|
|
->integerNode('port')->defaultValue(27017)->end() |
|
187
|
|
|
->scalarNode('host')->isRequired()->end() |
|
188
|
|
|
->scalarNode('user')->defaultValue(null)->end() |
|
189
|
|
|
->scalarNode('password')->defaultValue(null)->end() |
|
190
|
|
|
->end() |
|
191
|
|
|
->end() |
|
192
|
|
|
->end() |
|
193
|
|
|
->end() |
|
194
|
|
|
->end() |
|
195
|
|
|
|
|
196
|
|
|
->arrayNode('memcached') |
|
197
|
|
|
->children() |
|
198
|
|
|
->scalarNode('prefix')->isRequired()->end() |
|
199
|
|
|
->arrayNode('servers') |
|
200
|
|
|
->prototype('array') |
|
201
|
|
|
->children() |
|
202
|
|
|
->integerNode('port')->defaultValue(11211)->end() |
|
203
|
|
|
->scalarNode('host')->defaultValue('localhost')->end() |
|
204
|
|
|
->integerNode('weight')->defaultValue(0)->end() |
|
205
|
|
|
->end() |
|
206
|
|
|
->end() |
|
207
|
|
|
->end() |
|
208
|
|
|
->end() |
|
209
|
|
|
->end() |
|
210
|
|
|
|
|
211
|
|
|
->arrayNode('predis') |
|
212
|
|
|
->children() |
|
213
|
|
|
->arrayNode('servers') |
|
214
|
|
|
->prototype('array') |
|
215
|
|
|
->children() |
|
216
|
|
|
->integerNode('port')->defaultValue(6379)->end() |
|
217
|
|
|
->scalarNode('host')->defaultValue('localhost')->end() |
|
218
|
|
|
->integerNode('database')->isRequired()->end() |
|
219
|
|
|
->end() |
|
220
|
|
|
->end() |
|
221
|
|
|
->end() |
|
222
|
|
|
->end() |
|
223
|
|
|
->end() |
|
224
|
|
|
|
|
225
|
|
|
->arrayNode('apc') |
|
226
|
|
|
->children() |
|
227
|
|
|
->scalarNode('prefix')->isRequired()->end() |
|
228
|
|
|
->end() |
|
229
|
|
|
->end() |
|
230
|
|
|
->end() |
|
231
|
|
|
->end() |
|
232
|
|
|
; |
|
233
|
|
|
|
|
234
|
|
|
return $treeBuilder; |
|
235
|
|
|
} |
|
236
|
|
|
} |
|
237
|
|
|
|