1 <?php
declare(strict_types
=1);
4 * This file is part of the Rapsys UserBundle package.
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Rapsys\UserBundle\DependencyInjection
;
14 use Rapsys\UserBundle\RapsysUserBundle
;
16 use Symfony\Component\Config\Definition\Builder\TreeBuilder
;
17 use Symfony\Component\Config\Definition\ConfigurationInterface
;
22 * This is the class that validates and merges configuration from your app/config files.
24 * @link http://symfony.com/doc/current/cookbook/bundles/configuration.html
26 class Configuration
implements ConfigurationInterface
{
30 public function getConfigTreeBuilder(): TreeBuilder
{
32 $treeBuilder = new TreeBuilder(RapsysUserBundle
::getAlias());
34 //The bundle default values
37 'civility' => 'Rapsys\\UserBundle\\Entity\\Civility',
38 'group' => 'Rapsys\\UserBundle\\Entity\\Group',
39 'user' => 'Rapsys\\UserBundle\\Entity\\User'
43 'civility' => 'Mister',
47 'locales' => [ 'en_gb' ],
48 'group' => [ 'Guest' ]
52 'name' => 'rapsysuser',
56 'name' => 'rapsysuser_confirm',
60 'name' => 'rapsysuser_edit',
64 'name' => 'rapsysuser_index',
68 'name' => 'rapsysuser_login',
72 'name' => 'rapsysuser_recover',
76 'name' => 'rapsysuser_register',
80 'translate' => [ 'site', 'title' ],
82 'address' => 'contact@example.com',
87 'admin' => [ 'mail' => true ],
89 'route' => [ 'home' => 'home_url' ],
91 'name' => '@RapsysUser/register.html.twig',
92 'edit' => 'Rapsys\UserBundle\Form\EditType',
93 'reset' => 'Rapsys\UserBundle\Form\ResetType',
94 'context' => [ 'title' => 'Edit' ]
98 'route' => [ 'home' => 'home_url' ],
100 'name' => '@RapsysUser/index.html.twig',
101 'context' => [ 'title' => 'Index' ]
105 'route' => [ 'home' => 'home_url', 'recover' => 'recover_url' ],
107 'name' => '@RapsysUser/login.html.twig',
108 'form' => 'Rapsys\UserBundle\Form\LoginType',
109 'context' => [ 'title' => 'Login' ]
113 'route' => [ 'home' => 'home_url', 'recover' => 'recover_url' ],
115 'name' => '@RapsysUser/recover.html.twig',
116 'form' => 'Rapsys\UserBundle\Form\RecoverType',
117 'context' => [ 'title' => 'Recover' ]
120 'subject' => 'Welcome back to %%site%%!',
121 'html' => '@RapsysUser/mail/recover.html.twig',
122 'text' => '@RapsysUser/mail/recover.text.twig',
129 'route' => [ 'home' => 'home_url', 'confirm' => 'confirm_url' ],
131 'name' => '@RapsysUser/register.html.twig',
132 'form' => 'Rapsys\UserBundle\Form\RegisterType',
133 'context' => [ 'title' => 'Register' ]
136 'subject' => 'Welcome to %%site%%!',
137 'html' => '@RapsysUser/mail/register.html.twig',
138 'text' => '@RapsysUser/mail/register.text.twig',
145 * Defines parameters allowed to configure the bundle
147 * @link https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
148 * @link http://symfony.com/doc/current/components/config/definition.html
149 * @link https://github.com/symfony/assetic-bundle/blob/master/DependencyInjection/Configuration.php#L63
151 * @see php bin/console config:dump-reference rapsysuser to dump default config
152 * @see php bin/console debug:config rapsysuser to dump config
157 ->addDefaultsIfNotSet()
160 ->addDefaultsIfNotSet()
161 #XXX: ignoreExtraKeys(bool $remove = true)
162 ->ignoreExtraKeys(false)
164 ->scalarNode('civility')->cannotBeEmpty()->defaultValue($defaults['class']['civility'])->end()
165 ->scalarNode('group')->cannotBeEmpty()->defaultValue($defaults['class']['group'])->end()
166 ->scalarNode('user')->cannotBeEmpty()->defaultValue($defaults['class']['user'])->end()
169 ->arrayNode('default')
170 ->addDefaultsIfNotSet()
171 #XXX: ignoreExtraKeys(bool $remove = true)
172 ->ignoreExtraKeys(false)
174 ->scalarNode('admin')->cannotBeEmpty()->defaultValue($defaults['default']['admin'])->end()
175 ->scalarNode('civility')->cannotBeEmpty()->defaultValue($defaults['default']['civility'])->end()
176 #TODO: see if we can't prevent key normalisation with ->normalizeKeys(false)
177 ->arrayNode('languages')
179 ->defaultValue($defaults['default']['languages'])
180 ->scalarPrototype()->end()
182 #TODO: see if we can't prevent key normalisation with ->normalizeKeys(false)
183 ->arrayNode('locales')
185 ->defaultValue($defaults['default']['locales'])
186 ->scalarPrototype()->end()
190 ->defaultValue($defaults['default']['group'])
191 ->scalarPrototype()->end()
196 ->addDefaultsIfNotSet()
198 ->arrayNode('confirm')
199 ->addDefaultsIfNotSet()
201 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['confirm']['name'])->end()
202 ->arrayNode('context')
204 ->defaultValue($defaults['route']['confirm']['context'])
205 ->scalarPrototype()->end()
210 ->addDefaultsIfNotSet()
212 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['edit']['name'])->end()
213 ->arrayNode('context')
215 ->defaultValue($defaults['route']['edit']['context'])
216 ->scalarPrototype()->end()
221 ->addDefaultsIfNotSet()
223 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['home']['name'])->end()
224 ->arrayNode('context')
226 ->defaultValue($defaults['route']['home']['context'])
227 ->scalarPrototype()->end()
232 ->addDefaultsIfNotSet()
234 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['index']['name'])->end()
235 ->arrayNode('context')
237 ->defaultValue($defaults['route']['index']['context'])
238 ->scalarPrototype()->end()
243 ->addDefaultsIfNotSet()
245 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['login']['name'])->end()
246 ->arrayNode('context')
248 ->defaultValue($defaults['route']['login']['context'])
249 ->scalarPrototype()->end()
253 ->arrayNode('recover')
254 ->addDefaultsIfNotSet()
256 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover']['name'])->end()
257 ->arrayNode('context')
259 ->defaultValue($defaults['route']['recover']['context'])
260 ->scalarPrototype()->end()
264 ->arrayNode('register')
265 ->addDefaultsIfNotSet()
267 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['register']['name'])->end()
268 ->arrayNode('context')
270 ->defaultValue($defaults['route']['register']['context'])
271 ->scalarPrototype()->end()
277 ->arrayNode('translate')
279 ->defaultValue($defaults['translate'])
280 ->scalarPrototype()->end()
282 ->arrayNode('contact')
283 ->addDefaultsIfNotSet()
285 ->scalarNode('address')->cannotBeEmpty()->defaultValue($defaults['contact']['address'])->end()
286 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['contact']['name'])->end()
289 ->arrayNode('context')
291 ->defaultValue($defaults['context'])
292 ->variablePrototype()->end()
295 ->addDefaultsIfNotSet()
299 ->defaultValue($defaults['edit']['admin'])
300 ->variablePrototype()->end()
304 ->defaultValue($defaults['edit']['field'])
305 ->variablePrototype()->end()
309 ->defaultValue($defaults['edit']['route'])
310 ->scalarPrototype()->end()
313 ->addDefaultsIfNotSet()
315 ->scalarNode('edit')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['edit'])->end()
316 ->scalarNode('reset')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['reset'])->end()
317 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['name'])->end()
318 ->arrayNode('context')
320 ->defaultValue($defaults['edit']['view']['context'])
321 ->variablePrototype()->end()
328 ->addDefaultsIfNotSet()
332 ->defaultValue($defaults['index']['route'])
333 ->scalarPrototype()->end()
336 ->addDefaultsIfNotSet()
338 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['index']['view']['name'])->end()
339 ->arrayNode('context')
341 ->defaultValue($defaults['index']['view']['context'])
342 ->variablePrototype()->end()
349 ->addDefaultsIfNotSet()
353 ->defaultValue($defaults['login']['route'])
354 ->scalarPrototype()->end()
357 ->addDefaultsIfNotSet()
359 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['login']['view']['name'])->end()
360 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['login']['view']['form'])->end()
361 ->arrayNode('context')
363 ->defaultValue($defaults['login']['view']['context'])
364 ->variablePrototype()->end()
370 ->arrayNode('recover')
371 ->addDefaultsIfNotSet()
375 ->defaultValue($defaults['recover']['route'])
376 ->scalarPrototype()->end()
379 ->addDefaultsIfNotSet()
381 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['name'])->end()
382 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['form'])->end()
383 ->arrayNode('context')
385 ->defaultValue($defaults['recover']['view']['context'])
386 ->variablePrototype()->end()
391 ->addDefaultsIfNotSet()
393 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['subject'])->end()
394 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['html'])->end()
395 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['text'])->end()
396 ->arrayNode('context')
398 ->defaultValue($defaults['recover']['mail']['context'])
399 ->variablePrototype()->end()
405 ->arrayNode('register')
406 ->addDefaultsIfNotSet()
410 ->defaultValue($defaults['edit']['admin'])
411 ->variablePrototype()->end()
415 ->defaultValue($defaults['register']['field'])
416 ->variablePrototype()->end()
420 ->defaultValue($defaults['register']['route'])
421 ->scalarPrototype()->end()
424 ->addDefaultsIfNotSet()
426 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
427 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
428 ->arrayNode('context')
430 ->defaultValue($defaults['register']['view']['context'])
431 ->variablePrototype()->end()
436 ->addDefaultsIfNotSet()
438 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['subject'])->end()
439 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['html'])->end()
440 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['text'])->end()
441 ->arrayNode('context')
443 ->defaultValue($defaults['register']['mail']['context'])
444 ->variablePrototype()->end()