]> Raphaël G. Git Repositories - userbundle/blob - DependencyInjection/Configuration.php
Php 8.x constructor style
[userbundle] / DependencyInjection / Configuration.php
1 <?php declare(strict_types=1);
2
3 /*
4 * This file is part of the Rapsys UserBundle package.
5 *
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
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 Rapsys\UserBundle\DependencyInjection;
13
14 use Symfony\Component\Config\Definition\Builder\TreeBuilder;
15 use Symfony\Component\Config\Definition\ConfigurationInterface;
16
17 use Rapsys\UserBundle\RapsysUserBundle;
18
19 /**
20 * This is the class that validates and merges configuration from your app/config files.
21 *
22 * @link http://symfony.com/doc/current/cookbook/bundles/configuration.html
23 *
24 * {@inheritdoc}
25 */
26 class Configuration implements ConfigurationInterface {
27 /**
28 * {@inheritdoc}
29 */
30 public function getConfigTreeBuilder(): TreeBuilder {
31 //Set tree builder
32 $treeBuilder = new TreeBuilder(RapsysUserBundle::getAlias());
33
34 //The bundle default values
35 $defaults = [
36 'class' => [
37 'civility' => 'Rapsys\\UserBundle\\Entity\\Civility',
38 'group' => 'Rapsys\\UserBundle\\Entity\\Group',
39 'user' => 'Rapsys\\UserBundle\\Entity\\User'
40 ],
41 'default' => [
42 'admin' => 'ROLE_ADMIN',
43 'civility' => 'Mister',
44 'group' => [ 'User' ]
45 ],
46 'route' => [
47 'confirm' => [
48 'name' => 'rapsys_user_confirm',
49 'context' => []
50 ],
51 'edit' => [
52 'name' => 'rapsys_user_edit',
53 'context' => []
54 ],
55 'index' => [
56 'name' => 'rapsys_user_index',
57 'context' => []
58 ],
59 'login' => [
60 'name' => 'rapsys_user_login',
61 'context' => []
62 ],
63 'recover' => [
64 'name' => 'rapsys_user_recover',
65 'context' => []
66 ],
67 'register' => [
68 'name' => 'rapsys_user_register',
69 'context' => []
70 ]
71 ],
72 'translate' => [],
73 'contact' => [
74 'address' => 'contact@example.com',
75 'name' => 'John Doe'
76 ],
77 'context' => [],
78 'edit' => [
79 'admin' => ['mail' => true, 'pseudonym' => true],
80 'field' => [],
81 'route' => ['index' => 'index_url'],
82 'view' => [
83 'name' => '@RapsysUser/form/register.html.twig',
84 'edit' => 'Rapsys\UserBundle\Form\EditType',
85 'reset' => 'Rapsys\UserBundle\Form\ResetType',
86 'context' => []
87 ]
88 ],
89 'index' => [
90 'route' => ['index' => 'index_url'],
91 'view' => [
92 'name' => '@RapsysUser/form/index.html.twig',
93 'context' => []
94 ]
95 ],
96 'login' => [
97 'route' => ['index' => 'index_url'],
98 'view' => [
99 'name' => '@RapsysUser/form/login.html.twig',
100 'form' => 'Rapsys\UserBundle\Form\LoginType',
101 'context' => []
102 ]
103 ],
104 'recover' => [
105 'route' => ['index' => 'index_url', 'recover' => 'recover_url'],
106 'view' => [
107 'name' => '@RapsysUser/form/recover.html.twig',
108 'form' => 'Rapsys\UserBundle\Form\RecoverType',
109 'context' => []
110 ],
111 'mail' => [
112 'subject' => 'Welcome back!',
113 'html' => '@RapsysUser/mail/recover.html.twig',
114 'text' => '@RapsysUser/mail/recover.text.twig',
115 'context' => []
116 ]
117 ],
118 'register' => [
119 'admin' => [],
120 'field' => [],
121 'route' => ['index' => 'index_url', 'confirm' => 'confirm_url'],
122 'view' => [
123 'name' => '@RapsysUser/form/register.html.twig',
124 'form' => 'Rapsys\UserBundle\Form\RegisterType',
125 'context' => []
126 ],
127 'mail' => [
128 'subject' => 'Welcome!',
129 'html' => '@RapsysUser/mail/register.html.twig',
130 'text' => '@RapsysUser/mail/register.text.twig',
131 'context' => []
132 ]
133 ]
134 ];
135
136 /**
137 * Defines parameters allowed to configure the bundle
138 *
139 * @link https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
140 * @link http://symfony.com/doc/current/components/config/definition.html
141 * @link https://github.com/symfony/assetic-bundle/blob/master/DependencyInjection/Configuration.php#L63
142 *
143 * @see php bin/console config:dump-reference rapsys_user to dump default config
144 * @see php bin/console debug:config rapsys_user to dump config
145 */
146 $treeBuilder
147 //Parameters
148 ->getRootNode()
149 ->addDefaultsIfNotSet()
150 ->children()
151 ->arrayNode('class')
152 ->addDefaultsIfNotSet()
153 ->ignoreExtraKeys()
154 ->children()
155 ->scalarNode('civility')->cannotBeEmpty()->defaultValue($defaults['class']['civility'])->end()
156 ->scalarNode('group')->cannotBeEmpty()->defaultValue($defaults['class']['group'])->end()
157 ->scalarNode('user')->cannotBeEmpty()->defaultValue($defaults['class']['user'])->end()
158 ->end()
159 ->end()
160 ->arrayNode('default')
161 ->addDefaultsIfNotSet()
162 ->ignoreExtraKeys()
163 ->children()
164 ->scalarNode('admin')->cannotBeEmpty()->defaultValue($defaults['default']['admin'])->end()
165 ->scalarNode('civility')->cannotBeEmpty()->defaultValue($defaults['default']['civility'])->end()
166 ->arrayNode('group')
167 ->treatNullLike([])
168 ->defaultValue($defaults['default']['group'])
169 ->scalarPrototype()->end()
170 ->end()
171 ->end()
172 ->end()
173 ->arrayNode('route')
174 ->addDefaultsIfNotSet()
175 ->children()
176 ->arrayNode('confirm')
177 ->addDefaultsIfNotSet()
178 ->children()
179 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['confirm']['name'])->end()
180 ->arrayNode('context')
181 ->treatNullLike([])
182 ->defaultValue($defaults['route']['confirm']['context'])
183 ->scalarPrototype()->end()
184 ->end()
185 ->end()
186 ->end()
187 ->arrayNode('index')
188 ->addDefaultsIfNotSet()
189 ->children()
190 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['index']['name'])->end()
191 ->arrayNode('context')
192 ->treatNullLike([])
193 ->defaultValue($defaults['route']['index']['context'])
194 ->scalarPrototype()->end()
195 ->end()
196 ->end()
197 ->end()
198 ->arrayNode('edit')
199 ->addDefaultsIfNotSet()
200 ->children()
201 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['edit']['name'])->end()
202 ->arrayNode('context')
203 ->treatNullLike([])
204 ->defaultValue($defaults['route']['edit']['context'])
205 ->scalarPrototype()->end()
206 ->end()
207 ->end()
208 ->end()
209 ->arrayNode('login')
210 ->addDefaultsIfNotSet()
211 ->children()
212 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['login']['name'])->end()
213 ->arrayNode('context')
214 ->treatNullLike([])
215 ->defaultValue($defaults['route']['login']['context'])
216 ->scalarPrototype()->end()
217 ->end()
218 ->end()
219 ->end()
220 ->arrayNode('recover')
221 ->addDefaultsIfNotSet()
222 ->children()
223 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover']['name'])->end()
224 ->arrayNode('context')
225 ->treatNullLike([])
226 ->defaultValue($defaults['route']['recover']['context'])
227 ->scalarPrototype()->end()
228 ->end()
229 ->end()
230 ->end()
231 ->arrayNode('register')
232 ->addDefaultsIfNotSet()
233 ->children()
234 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['register']['name'])->end()
235 ->arrayNode('context')
236 ->treatNullLike([])
237 ->defaultValue($defaults['route']['register']['context'])
238 ->scalarPrototype()->end()
239 ->end()
240 ->end()
241 ->end()
242 ->end()
243 ->end()
244 ->arrayNode('translate')
245 ->treatNullLike([])
246 ->defaultValue($defaults['translate'])
247 ->scalarPrototype()->end()
248 ->end()
249 ->arrayNode('contact')
250 ->addDefaultsIfNotSet()
251 ->children()
252 ->scalarNode('address')->cannotBeEmpty()->defaultValue($defaults['contact']['address'])->end()
253 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['contact']['name'])->end()
254 ->end()
255 ->end()
256 ->arrayNode('context')
257 ->treatNullLike([])
258 ->defaultValue($defaults['context'])
259 ->variablePrototype()->end()
260 ->end()
261 ->arrayNode('edit')
262 ->addDefaultsIfNotSet()
263 ->children()
264 ->arrayNode('admin')
265 ->treatNullLike([])
266 ->defaultValue($defaults['edit']['admin'])
267 ->variablePrototype()->end()
268 ->end()
269 ->arrayNode('field')
270 ->treatNullLike([])
271 ->defaultValue($defaults['edit']['field'])
272 ->variablePrototype()->end()
273 ->end()
274 ->arrayNode('route')
275 ->treatNullLike([])
276 ->defaultValue($defaults['edit']['route'])
277 ->scalarPrototype()->end()
278 ->end()
279 ->arrayNode('view')
280 ->addDefaultsIfNotSet()
281 ->children()
282 ->scalarNode('edit')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['edit'])->end()
283 ->scalarNode('reset')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['reset'])->end()
284 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['name'])->end()
285 ->arrayNode('context')
286 ->treatNullLike([])
287 ->defaultValue($defaults['edit']['view']['context'])
288 ->variablePrototype()->end()
289 ->end()
290 ->end()
291 ->end()
292 ->end()
293 ->end()
294 ->arrayNode('index')
295 ->addDefaultsIfNotSet()
296 ->children()
297 ->arrayNode('route')
298 ->treatNullLike([])
299 ->defaultValue($defaults['index']['route'])
300 ->scalarPrototype()->end()
301 ->end()
302 ->arrayNode('view')
303 ->addDefaultsIfNotSet()
304 ->children()
305 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['index']['view']['name'])->end()
306 ->arrayNode('context')
307 ->treatNullLike([])
308 ->defaultValue($defaults['index']['view']['context'])
309 ->variablePrototype()->end()
310 ->end()
311 ->end()
312 ->end()
313 ->end()
314 ->end()
315 ->arrayNode('login')
316 ->addDefaultsIfNotSet()
317 ->children()
318 ->arrayNode('route')
319 ->treatNullLike([])
320 ->defaultValue($defaults['login']['route'])
321 ->scalarPrototype()->end()
322 ->end()
323 ->arrayNode('view')
324 ->addDefaultsIfNotSet()
325 ->children()
326 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['login']['view']['name'])->end()
327 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['login']['view']['form'])->end()
328 ->arrayNode('context')
329 ->treatNullLike([])
330 ->defaultValue($defaults['login']['view']['context'])
331 ->variablePrototype()->end()
332 ->end()
333 ->end()
334 ->end()
335 ->end()
336 ->end()
337 ->arrayNode('recover')
338 ->addDefaultsIfNotSet()
339 ->children()
340 ->arrayNode('route')
341 ->treatNullLike([])
342 ->defaultValue($defaults['recover']['route'])
343 ->scalarPrototype()->end()
344 ->end()
345 ->arrayNode('view')
346 ->addDefaultsIfNotSet()
347 ->children()
348 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['name'])->end()
349 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['form'])->end()
350 ->arrayNode('context')
351 ->treatNullLike([])
352 ->defaultValue($defaults['recover']['view']['context'])
353 ->variablePrototype()->end()
354 ->end()
355 ->end()
356 ->end()
357 ->arrayNode('mail')
358 ->addDefaultsIfNotSet()
359 ->children()
360 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['subject'])->end()
361 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['html'])->end()
362 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['text'])->end()
363 ->arrayNode('context')
364 ->treatNullLike([])
365 ->defaultValue($defaults['recover']['mail']['context'])
366 ->variablePrototype()->end()
367 ->end()
368 ->end()
369 ->end()
370 ->end()
371 ->end()
372 ->arrayNode('register')
373 ->addDefaultsIfNotSet()
374 ->children()
375 ->arrayNode('admin')
376 ->treatNullLike([])
377 ->defaultValue($defaults['edit']['admin'])
378 ->variablePrototype()->end()
379 ->end()
380 ->arrayNode('field')
381 ->treatNullLike([])
382 ->defaultValue($defaults['register']['field'])
383 ->variablePrototype()->end()
384 ->end()
385 ->arrayNode('route')
386 ->treatNullLike([])
387 ->defaultValue($defaults['register']['route'])
388 ->scalarPrototype()->end()
389 ->end()
390 ->arrayNode('view')
391 ->addDefaultsIfNotSet()
392 ->children()
393 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
394 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
395 ->arrayNode('context')
396 ->treatNullLike([])
397 ->defaultValue($defaults['register']['view']['context'])
398 ->variablePrototype()->end()
399 ->end()
400 ->end()
401 ->end()
402 ->arrayNode('mail')
403 ->addDefaultsIfNotSet()
404 ->children()
405 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['subject'])->end()
406 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['html'])->end()
407 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['text'])->end()
408 ->arrayNode('context')
409 ->treatNullLike([])
410 ->defaultValue($defaults['register']['mail']['context'])
411 ->variablePrototype()->end()
412 ->end()
413 ->end()
414 ->end()
415 ->end()
416 ->end()
417 ->end()
418 ->end();
419
420 return $treeBuilder;
421 }
422 }