1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sludio\HelperBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
6
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
7
|
|
|
use Sludio\HelperBundle\Guzzle\DataCollector\GuzzleCollector; |
8
|
|
|
use GuzzleHttp\MessageFormatter; |
9
|
|
|
|
10
|
|
|
class Configuration implements ConfigurationInterface |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* {@inheritdoc} |
14
|
|
|
*/ |
15
|
|
|
public function getConfigTreeBuilder() |
16
|
|
|
{ |
17
|
|
|
$treeBuilder = new TreeBuilder(); |
18
|
|
|
$rootNode = $treeBuilder->root('sludio_helper'); |
19
|
|
|
|
20
|
|
|
// @formatter:off |
21
|
|
|
$rootNode |
22
|
|
|
->children() |
23
|
|
|
->arrayNode('extensions') |
24
|
|
|
->addDefaultsIfNotSet() |
25
|
|
|
->children() |
26
|
|
|
->arrayNode('captcha') |
27
|
|
|
->addDefaultsIfNotSet() |
28
|
|
|
->canBeEnabled() |
29
|
|
|
->children() |
30
|
|
|
->arrayNode('clients') |
31
|
|
|
->prototype('array') |
32
|
|
|
->prototype('variable')->end() |
33
|
|
|
->end() |
34
|
|
|
->end() |
35
|
|
|
->end() |
36
|
|
|
->end() |
37
|
|
|
->arrayNode('guzzle') |
38
|
|
|
->addDefaultsIfNotSet() |
39
|
|
|
->canBeEnabled() |
40
|
|
|
->children() |
41
|
|
|
->arrayNode('profiler') |
42
|
|
|
->canBeEnabled() |
43
|
|
|
->children() |
44
|
|
|
->integerNode('max_body_size') |
45
|
|
|
->defaultValue(GuzzleCollector::MAX_BODY_SIZE) |
46
|
|
|
->end() |
47
|
|
|
->end() |
48
|
|
|
->end() |
49
|
|
|
->arrayNode('logger') |
50
|
|
|
->canBeEnabled() |
51
|
|
|
->children() |
52
|
|
|
->scalarNode('service')->defaultValue(null)->end() |
53
|
|
|
->scalarNode('format') |
54
|
|
|
->beforeNormalization() |
55
|
|
|
->ifInArray(['clf', 'debug', 'short']) |
56
|
|
|
->then(function($v) { |
57
|
|
|
return constant('GuzzleHttp\MessageFormatter::'.strtoupper($v)); |
58
|
|
|
}) |
59
|
|
|
->end() |
60
|
|
|
->defaultValue(MessageFormatter::CLF) |
61
|
|
|
->end() |
62
|
|
|
->scalarNode('level') |
63
|
|
|
->beforeNormalization() |
64
|
|
|
->ifInArray([ |
65
|
|
|
'emergency', 'alert', 'critical', 'error', |
66
|
|
|
'warning', 'notice', 'info', 'debug', |
67
|
|
|
]) |
68
|
|
|
->then(function($v) { |
69
|
|
|
return constant('Psr\Log\LogLevel::'.strtoupper($v)); |
70
|
|
|
}) |
71
|
|
|
->end() |
72
|
|
|
->defaultValue('debug') |
73
|
|
|
->end() |
74
|
|
|
->end() |
75
|
|
|
->end() |
76
|
|
|
->arrayNode('cache') |
77
|
|
|
->canBeEnabled() |
78
|
|
|
->validate() |
79
|
|
|
->ifTrue(function($v) { |
80
|
|
|
return $v['enabled'] && null === $v['adapter']; |
81
|
|
|
}) |
82
|
|
|
->thenInvalid('The \'sludio_helper.guzzle.cache.adapter\' key is mandatory if you enable the cache middleware') |
83
|
|
|
->end() |
84
|
|
|
->children() |
85
|
|
|
->scalarNode('adapter')->defaultNull()->end() |
86
|
|
|
->booleanNode('disabled')->defaultValue(null)->end() |
87
|
|
|
->end() |
88
|
|
|
->end() |
89
|
|
|
->arrayNode('clients') |
90
|
|
|
->useAttributeAsKey('name') |
91
|
|
|
->prototype('array') |
92
|
|
|
->children() |
93
|
|
|
->scalarNode('class') |
94
|
|
|
->defaultValue('GuzzleHttp\Client') |
95
|
|
|
->end() |
96
|
|
|
->booleanNode('lazy') |
97
|
|
|
->defaultFalse() |
98
|
|
|
->end() |
99
|
|
|
->variableNode('config')->end() |
100
|
|
|
->arrayNode('middleware') |
101
|
|
|
->prototype('scalar')->end() |
102
|
|
|
->end() |
103
|
|
|
->scalarNode('alias')->defaultNull()->end() |
104
|
|
|
->end() |
105
|
|
|
->end() |
106
|
|
|
->end() |
107
|
|
|
->arrayNode('mock') |
108
|
|
|
->canBeEnabled() |
109
|
|
|
->children() |
110
|
|
|
->scalarNode('storage_path')->isRequired()->end() |
111
|
|
|
->scalarNode('mode')->defaultValue('replay')->end() |
112
|
|
|
->arrayNode('request_headers_blacklist') |
113
|
|
|
->prototype('scalar')->end() |
114
|
|
|
->end() |
115
|
|
|
->arrayNode('response_headers_blacklist') |
116
|
|
|
->prototype('scalar')->end() |
117
|
|
|
->end() |
118
|
|
|
->end() |
119
|
|
|
->end() |
120
|
|
|
->end() |
121
|
|
|
->end() |
122
|
|
|
->arrayNode('lexik') |
123
|
|
|
->addDefaultsIfNotSet() |
124
|
|
|
->canBeEnabled() |
125
|
|
|
->children() |
126
|
|
|
->scalarNode('default_domain')->defaultValue('messages')->end() |
127
|
|
|
->arrayNode('default_selections') |
128
|
|
|
->addDefaultsIfNotSet() |
129
|
|
|
->children() |
130
|
|
|
->booleanNode('non_translated_only')->defaultValue(false)->end() |
131
|
|
|
->end() |
132
|
|
|
->end() |
133
|
|
|
->arrayNode('empty_prefixes') |
134
|
|
|
->defaultValue(['__', 'new_', '']) |
135
|
|
|
->prototype('array')->end() |
136
|
|
|
->end() |
137
|
|
|
->arrayNode('editable') |
138
|
|
|
->addDefaultsIfNotSet() |
139
|
|
|
->children() |
140
|
|
|
->scalarNode('type')->defaultValue('textarea')->end() |
141
|
|
|
->scalarNode('emptytext')->defaultValue('Empty')->end() |
142
|
|
|
->end() |
143
|
|
|
->end() |
144
|
|
|
->end() |
145
|
|
|
->end() |
146
|
|
|
->arrayNode('oauth') |
147
|
|
|
->addDefaultsIfNotSet() |
148
|
|
|
->canBeEnabled() |
149
|
|
|
->children() |
150
|
|
|
->arrayNode('clients') |
151
|
|
|
->prototype('array') |
152
|
|
|
->prototype('variable')->end() |
153
|
|
|
->end() |
154
|
|
|
->end() |
155
|
|
|
->arrayNode('custom_providers') |
156
|
|
|
->prototype('array') |
157
|
|
|
->prototype('variable')->end() |
158
|
|
|
->end() |
159
|
|
|
->end() |
160
|
|
|
->end() |
161
|
|
|
->end() |
162
|
|
|
->arrayNode('openid') |
163
|
|
|
->addDefaultsIfNotSet() |
164
|
|
|
->canBeEnabled() |
165
|
|
|
->children() |
166
|
|
|
->arrayNode('clients') |
167
|
|
|
->prototype('array') |
168
|
|
|
->prototype('variable')->end() |
169
|
|
|
->end() |
170
|
|
|
->end() |
171
|
|
|
->end() |
172
|
|
|
->end() |
173
|
|
|
->arrayNode('openidconnect') |
174
|
|
|
->addDefaultsIfNotSet() |
175
|
|
|
->canBeEnabled() |
176
|
|
|
->children() |
177
|
|
|
->arrayNode('clients') |
178
|
|
|
->prototype('array') |
179
|
|
|
->prototype('variable')->end() |
180
|
|
|
->end() |
181
|
|
|
->end() |
182
|
|
|
->end() |
183
|
|
|
->end() |
184
|
|
|
->arrayNode('pagination') |
185
|
|
|
->addDefaultsIfNotSet() |
186
|
|
|
->canBeEnabled() |
187
|
|
|
->children() |
188
|
|
|
->arrayNode('behaviour') |
189
|
|
|
->prototype('array') |
190
|
|
|
->prototype('variable')->end() |
191
|
|
|
->end() |
192
|
|
|
->end() |
193
|
|
|
->end() |
194
|
|
|
->end() |
195
|
|
|
->arrayNode('position') |
196
|
|
|
->addDefaultsIfNotSet() |
197
|
|
|
->canBeEnabled() |
198
|
|
|
->children() |
199
|
|
|
->arrayNode('field') |
200
|
|
|
->addDefaultsIfNotSet() |
201
|
|
|
->children() |
202
|
|
|
->scalarNode('default') |
203
|
|
|
->defaultValue('position') |
204
|
|
|
->end() |
205
|
|
|
->arrayNode('entities') |
206
|
|
|
->prototype('scalar')->end() |
207
|
|
|
->end() |
208
|
|
|
->end() |
209
|
|
|
->end() |
210
|
|
|
->end() |
211
|
|
|
->end() |
212
|
|
|
->arrayNode('script') |
213
|
|
|
->addDefaultsIfNotSet() |
214
|
|
|
->canBeEnabled() |
215
|
|
|
->children() |
216
|
|
|
->booleanNode('short_functions') |
217
|
|
|
->defaultValue(false) |
218
|
|
|
->end() |
219
|
|
|
->end() |
220
|
|
|
->end() |
221
|
|
|
->arrayNode('sitemap') |
222
|
|
|
->addDefaultsIfNotSet() |
223
|
|
|
->canBeEnabled() |
224
|
|
|
->children() |
225
|
|
|
->scalarNode('base_host') |
226
|
|
|
->defaultValue(null) |
227
|
|
|
->end() |
228
|
|
|
->scalarNode('limit') |
229
|
|
|
->defaultValue(null) |
230
|
|
|
->end() |
231
|
|
|
->enumNode('format') |
232
|
|
|
->values(['simple', 'rich']) |
233
|
|
|
->defaultValue('simple') |
234
|
|
|
->end() |
235
|
|
|
->enumNode('type') |
236
|
|
|
->values(['simple', 'gz']) |
237
|
|
|
->defaultValue('simple') |
238
|
|
|
->end() |
239
|
|
|
->end() |
240
|
|
|
->end() |
241
|
|
|
->arrayNode('translatable') |
242
|
|
|
->addDefaultsIfNotSet() |
243
|
|
|
->canBeEnabled() |
244
|
|
|
->children() |
245
|
|
|
->arrayNode('locales') |
246
|
|
|
->beforeNormalization() |
247
|
|
|
->ifString() |
248
|
|
|
->then(function($v) { |
249
|
|
|
return preg_split('/\s*,\s*/', $v); |
250
|
|
|
}) |
251
|
|
|
->end() |
252
|
|
|
->prototype('scalar')->end() |
253
|
|
|
->end() |
254
|
|
|
->scalarNode('default_locale') |
255
|
|
|
->defaultValue('en') |
256
|
|
|
->end() |
257
|
|
|
->scalarNode('template') |
258
|
|
|
->defaultValue('SludioHelperBundle:Translatable:translations.html.twig') |
259
|
|
|
->end() |
260
|
|
|
->scalarNode('table') |
261
|
|
|
->defaultValue('sludio_helper_translation') |
262
|
|
|
->end() |
263
|
|
|
->scalarNode('manager') |
264
|
|
|
->defaultValue('default') |
265
|
|
|
->end() |
266
|
|
|
->arrayNode('entities') |
267
|
|
|
->useAttributeAsKey('name') |
268
|
|
|
->prototype('array') |
269
|
|
|
->children() |
270
|
|
|
->scalarNode('entity') |
271
|
|
|
->defaultValue(null) |
272
|
|
|
->end() |
273
|
|
|
->arrayNode('fields') |
274
|
|
|
->useAttributeAsKey('name') |
275
|
|
|
->prototype('array') |
276
|
|
|
->children() |
277
|
|
|
->enumNode('class') |
278
|
|
|
->values(['titled', 'slugged', 'ck_item', null]) |
279
|
|
|
->defaultValue(null) |
280
|
|
|
->end() |
281
|
|
|
->enumNode('type') |
282
|
|
|
->values(['text', 'ckeditor']) |
283
|
|
|
->defaultValue('text') |
284
|
|
|
->end() |
285
|
|
|
->end() |
286
|
|
|
->end() |
287
|
|
|
->end() |
288
|
|
|
->end() |
289
|
|
|
->end() |
290
|
|
|
->end() |
291
|
|
|
->end() |
292
|
|
|
->end() |
293
|
|
|
->end() |
294
|
|
|
->end() |
295
|
|
|
->arrayNode('other') |
296
|
|
|
->addDefaultsIfNotSet() |
297
|
|
|
->children() |
298
|
|
|
->arrayNode('logger') |
299
|
|
|
->addDefaultsIfNotSet() |
300
|
|
|
->children() |
301
|
|
|
->scalarNode('class') |
302
|
|
|
->defaultValue('Sludio\HelperBundle\Logger\SludioLogger') |
303
|
|
|
->end() |
304
|
|
|
->end() |
305
|
|
|
->end() |
306
|
|
|
->arrayNode('redis') |
307
|
|
|
->addDefaultsIfNotSet() |
308
|
|
|
->children() |
309
|
|
|
->scalarNode('translation') |
310
|
|
|
->defaultValue('session') |
311
|
|
|
->end() |
312
|
|
|
->scalarNode('guzzle') |
313
|
|
|
->defaultValue('session') |
314
|
|
|
->end() |
315
|
|
|
->end() |
316
|
|
|
->end() |
317
|
|
|
->arrayNode('entity') |
318
|
|
|
->addDefaultsIfNotSet() |
319
|
|
|
->children() |
320
|
|
|
->scalarNode('manager') |
321
|
|
|
->defaultValue('default') |
322
|
|
|
->end() |
323
|
|
|
->end() |
324
|
|
|
->end() |
325
|
|
|
->scalarNode('locale') |
326
|
|
|
->defaultValue('en') |
327
|
|
|
->end() |
328
|
|
|
->end() |
329
|
|
|
->end() |
330
|
|
|
->end() |
331
|
|
|
; |
332
|
|
|
// @formatter:on |
333
|
|
|
|
334
|
|
|
return $treeBuilder; |
335
|
|
|
} |
336
|
|
|
} |
337
|
|
|
|