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 Symfony\Component\Config\Definition\Builder\TreeBuilder
;
15 use Symfony\Component\Config\Definition\ConfigurationInterface
;
17 use Rapsys\UserBundle\RapsysUserBundle
;
20 * This is the class that validates and merges configuration from your app/config files.
22 * @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'
42 'admin' => 'ROLE_ADMIN',
43 'civility' => 'Mister',
47 'locales' => [ 'en_gb' ],
52 'name' => 'rapsys_user_confirm',
56 'name' => 'rapsys_user_edit',
60 'name' => 'rapsys_user_index',
64 'name' => 'rapsys_user_login',
68 'name' => 'rapsys_user_recover',
72 'name' => 'rapsys_user_register',
78 'address' => 'contact@example.com',
83 'admin' => ['mail' => true, 'pseudonym' => true],
85 'route' => ['index' => 'index_url'],
87 'name' => '@RapsysUser/form/register.html.twig',
88 'edit' => 'Rapsys\UserBundle\Form\EditType',
89 'reset' => 'Rapsys\UserBundle\Form\ResetType',
94 'route' => ['index' => 'index_url'],
96 'name' => '@RapsysUser/form/index.html.twig',
101 'route' => ['index' => 'index_url'],
103 'name' => '@RapsysUser/form/login.html.twig',
104 'form' => 'Rapsys\UserBundle\Form\LoginType',
109 'route' => ['index' => 'index_url', 'recover' => 'recover_url'],
111 'name' => '@RapsysUser/form/recover.html.twig',
112 'form' => 'Rapsys\UserBundle\Form\RecoverType',
116 'subject' => 'Welcome back!',
117 'html' => '@RapsysUser/mail/recover.html.twig',
118 'text' => '@RapsysUser/mail/recover.text.twig',
125 'route' => ['index' => 'index_url', 'confirm' => 'confirm_url'],
127 'name' => '@RapsysUser/form/register.html.twig',
128 'form' => 'Rapsys\UserBundle\Form\RegisterType',
132 'subject' => 'Welcome!',
133 'html' => '@RapsysUser/mail/register.html.twig',
134 'text' => '@RapsysUser/mail/register.text.twig',
141 * Defines parameters allowed to configure the bundle
143 * @link https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
144 * @link http://symfony.com/doc/current/components/config/definition.html
145 * @link https://github.com/symfony/assetic-bundle/blob/master/DependencyInjection/Configuration.php#L63
147 * @see php bin/console config:dump-reference rapsys_user to dump default config
148 * @see php bin/console debug:config rapsys_user to dump config
153 ->addDefaultsIfNotSet()
156 ->addDefaultsIfNotSet()
157 #XXX: ignoreExtraKeys(bool $remove = true)
158 ->ignoreExtraKeys(false)
160 ->scalarNode('civility')->cannotBeEmpty()->defaultValue($defaults['class']['civility'])->end()
161 ->scalarNode('group')->cannotBeEmpty()->defaultValue($defaults['class']['group'])->end()
162 ->scalarNode('user')->cannotBeEmpty()->defaultValue($defaults['class']['user'])->end()
165 ->arrayNode('default')
166 ->addDefaultsIfNotSet()
167 #XXX: ignoreExtraKeys(bool $remove = true)
168 ->ignoreExtraKeys(false)
170 ->scalarNode('admin')->cannotBeEmpty()->defaultValue($defaults['default']['admin'])->end()
171 ->scalarNode('civility')->cannotBeEmpty()->defaultValue($defaults['default']['civility'])->end()
172 #TODO: see if we can't prevent key normalisation with ->normalizeKeys(false)
173 ->arrayNode('languages')
175 ->defaultValue($defaults['default']['languages'])
176 ->scalarPrototype()->end()
178 #TODO: see if we can't prevent key normalisation with ->normalizeKeys(false)
179 ->arrayNode('locales')
181 ->defaultValue($defaults['default']['locales'])
182 ->scalarPrototype()->end()
186 ->defaultValue($defaults['default']['group'])
187 ->scalarPrototype()->end()
192 ->addDefaultsIfNotSet()
194 ->arrayNode('confirm')
195 ->addDefaultsIfNotSet()
197 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['confirm']['name'])->end()
198 ->arrayNode('context')
200 ->defaultValue($defaults['route']['confirm']['context'])
201 ->scalarPrototype()->end()
206 ->addDefaultsIfNotSet()
208 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['index']['name'])->end()
209 ->arrayNode('context')
211 ->defaultValue($defaults['route']['index']['context'])
212 ->scalarPrototype()->end()
217 ->addDefaultsIfNotSet()
219 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['edit']['name'])->end()
220 ->arrayNode('context')
222 ->defaultValue($defaults['route']['edit']['context'])
223 ->scalarPrototype()->end()
228 ->addDefaultsIfNotSet()
230 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['login']['name'])->end()
231 ->arrayNode('context')
233 ->defaultValue($defaults['route']['login']['context'])
234 ->scalarPrototype()->end()
238 ->arrayNode('recover')
239 ->addDefaultsIfNotSet()
241 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover']['name'])->end()
242 ->arrayNode('context')
244 ->defaultValue($defaults['route']['recover']['context'])
245 ->scalarPrototype()->end()
249 ->arrayNode('register')
250 ->addDefaultsIfNotSet()
252 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['register']['name'])->end()
253 ->arrayNode('context')
255 ->defaultValue($defaults['route']['register']['context'])
256 ->scalarPrototype()->end()
262 ->arrayNode('translate')
264 ->defaultValue($defaults['translate'])
265 ->scalarPrototype()->end()
267 ->arrayNode('contact')
268 ->addDefaultsIfNotSet()
270 ->scalarNode('address')->cannotBeEmpty()->defaultValue($defaults['contact']['address'])->end()
271 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['contact']['name'])->end()
274 ->arrayNode('context')
276 ->defaultValue($defaults['context'])
277 ->variablePrototype()->end()
280 ->addDefaultsIfNotSet()
284 ->defaultValue($defaults['edit']['admin'])
285 ->variablePrototype()->end()
289 ->defaultValue($defaults['edit']['field'])
290 ->variablePrototype()->end()
294 ->defaultValue($defaults['edit']['route'])
295 ->scalarPrototype()->end()
298 ->addDefaultsIfNotSet()
300 ->scalarNode('edit')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['edit'])->end()
301 ->scalarNode('reset')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['reset'])->end()
302 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['name'])->end()
303 ->arrayNode('context')
305 ->defaultValue($defaults['edit']['view']['context'])
306 ->variablePrototype()->end()
313 ->addDefaultsIfNotSet()
317 ->defaultValue($defaults['index']['route'])
318 ->scalarPrototype()->end()
321 ->addDefaultsIfNotSet()
323 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['index']['view']['name'])->end()
324 ->arrayNode('context')
326 ->defaultValue($defaults['index']['view']['context'])
327 ->variablePrototype()->end()
334 ->addDefaultsIfNotSet()
338 ->defaultValue($defaults['login']['route'])
339 ->scalarPrototype()->end()
342 ->addDefaultsIfNotSet()
344 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['login']['view']['name'])->end()
345 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['login']['view']['form'])->end()
346 ->arrayNode('context')
348 ->defaultValue($defaults['login']['view']['context'])
349 ->variablePrototype()->end()
355 ->arrayNode('recover')
356 ->addDefaultsIfNotSet()
360 ->defaultValue($defaults['recover']['route'])
361 ->scalarPrototype()->end()
364 ->addDefaultsIfNotSet()
366 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['name'])->end()
367 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['form'])->end()
368 ->arrayNode('context')
370 ->defaultValue($defaults['recover']['view']['context'])
371 ->variablePrototype()->end()
376 ->addDefaultsIfNotSet()
378 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['subject'])->end()
379 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['html'])->end()
380 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['text'])->end()
381 ->arrayNode('context')
383 ->defaultValue($defaults['recover']['mail']['context'])
384 ->variablePrototype()->end()
390 ->arrayNode('register')
391 ->addDefaultsIfNotSet()
395 ->defaultValue($defaults['edit']['admin'])
396 ->variablePrototype()->end()
400 ->defaultValue($defaults['register']['field'])
401 ->variablePrototype()->end()
405 ->defaultValue($defaults['register']['route'])
406 ->scalarPrototype()->end()
409 ->addDefaultsIfNotSet()
411 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
412 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
413 ->arrayNode('context')
415 ->defaultValue($defaults['register']['view']['context'])
416 ->variablePrototype()->end()
421 ->addDefaultsIfNotSet()
423 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['subject'])->end()
424 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['html'])->end()
425 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['text'])->end()
426 ->arrayNode('context')
428 ->defaultValue($defaults['register']['mail']['context'])
429 ->variablePrototype()->end()