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 'group' => 'Rapsys\\UserBundle\\Entity\\Group',
38 'civility' => 'Rapsys\\UserBundle\\Entity\\Civility',
39 'user' => 'Rapsys\\UserBundle\\Entity\\User'
42 'admin' => 'ROLE_ADMIN',
43 'civility' => 'Mister',
48 'name' => 'rapsys_user_confirm',
52 'name' => 'rapsys_user_edit',
56 'name' => 'rapsys_user_index',
60 'name' => 'rapsys_user_login',
64 'name' => 'rapsys_user_recover',
68 'name' => 'rapsys_user_register',
77 'address' => 'contact@example.com',
82 'admin' => ['mail' => true, 'pseudonym' => true],
84 'route' => ['index' => 'index_url'],
86 'name' => '@RapsysUser/form/register.html.twig',
87 'edit' => 'Rapsys\UserBundle\Form\EditType',
88 'reset' => 'Rapsys\UserBundle\Form\ResetType',
93 'route' => ['index' => 'index_url'],
95 'name' => '@RapsysUser/form/index.html.twig',
100 'route' => ['index' => 'index_url'],
102 'name' => '@RapsysUser/form/login.html.twig',
103 'form' => 'Rapsys\UserBundle\Form\LoginType',
108 'route' => ['index' => 'index_url', 'recover' => 'recover_url'],
110 'name' => '@RapsysUser/form/recover.html.twig',
111 'form' => 'Rapsys\UserBundle\Form\RecoverType',
115 'subject' => 'Welcome back!',
116 'html' => '@RapsysUser/mail/recover.html.twig',
117 'text' => '@RapsysUser/mail/recover.text.twig',
124 'route' => ['index' => 'index_url', 'confirm' => 'confirm_url'],
126 'name' => '@RapsysUser/form/register.html.twig',
127 'form' => 'Rapsys\UserBundle\Form\RegisterType',
131 'subject' => 'Welcome!',
132 'html' => '@RapsysUser/mail/register.html.twig',
133 'text' => '@RapsysUser/mail/register.text.twig',
140 * Defines parameters allowed to configure the bundle
142 * @link https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
143 * @link http://symfony.com/doc/current/components/config/definition.html
144 * @link https://github.com/symfony/assetic-bundle/blob/master/DependencyInjection/Configuration.php#L63
146 * @see php bin/console config:dump-reference rapsys_user to dump default config
147 * @see php bin/console debug:config rapsys_user to dump config
152 ->addDefaultsIfNotSet()
156 ->defaultValue($defaults['class'])
157 ->scalarPrototype()->end()
159 ->arrayNode('default')
160 ->addDefaultsIfNotSet()
162 ->scalarNode('admin')->cannotBeEmpty()->defaultValue($defaults['default']['admin'])->end()
163 ->scalarNode('civility')->cannotBeEmpty()->defaultValue($defaults['default']['civility'])->end()
166 ->defaultValue($defaults['default']['group'])
167 ->scalarPrototype()->end()
172 ->addDefaultsIfNotSet()
174 ->arrayNode('confirm')
175 ->addDefaultsIfNotSet()
177 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['confirm']['name'])->end()
178 ->arrayNode('context')
180 ->defaultValue($defaults['route']['confirm']['context'])
181 ->scalarPrototype()->end()
186 ->addDefaultsIfNotSet()
188 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['index']['name'])->end()
189 ->arrayNode('context')
191 ->defaultValue($defaults['route']['index']['context'])
192 ->scalarPrototype()->end()
197 ->addDefaultsIfNotSet()
199 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['edit']['name'])->end()
200 ->arrayNode('context')
202 ->defaultValue($defaults['route']['edit']['context'])
203 ->scalarPrototype()->end()
208 ->addDefaultsIfNotSet()
210 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['login']['name'])->end()
211 ->arrayNode('context')
213 ->defaultValue($defaults['route']['login']['context'])
214 ->scalarPrototype()->end()
218 ->arrayNode('recover')
219 ->addDefaultsIfNotSet()
221 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover']['name'])->end()
222 ->arrayNode('context')
224 ->defaultValue($defaults['route']['recover']['context'])
225 ->scalarPrototype()->end()
229 ->arrayNode('register')
230 ->addDefaultsIfNotSet()
232 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['register']['name'])->end()
233 ->arrayNode('context')
235 ->defaultValue($defaults['route']['register']['context'])
236 ->scalarPrototype()->end()
242 ->arrayNode('translate')
244 ->defaultValue($defaults['translate'])
245 ->scalarPrototype()->end()
247 #TODO: see if we can't prevent key normalisation with ->normalizeKeys(false)
248 ->arrayNode('languages')
250 ->defaultValue($defaults['languages'])
251 ->scalarPrototype()->end()
253 ->arrayNode('contact')
254 ->addDefaultsIfNotSet()
256 ->scalarNode('address')->cannotBeEmpty()->defaultValue($defaults['contact']['address'])->end()
257 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['contact']['name'])->end()
260 ->arrayNode('context')
262 ->defaultValue($defaults['context'])
263 ->variablePrototype()->end()
266 ->addDefaultsIfNotSet()
270 ->defaultValue($defaults['edit']['admin'])
271 ->variablePrototype()->end()
275 ->defaultValue($defaults['edit']['field'])
276 ->variablePrototype()->end()
280 ->defaultValue($defaults['edit']['route'])
281 ->scalarPrototype()->end()
284 ->addDefaultsIfNotSet()
286 ->scalarNode('edit')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['edit'])->end()
287 ->scalarNode('reset')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['reset'])->end()
288 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['name'])->end()
289 ->arrayNode('context')
291 ->defaultValue($defaults['edit']['view']['context'])
292 ->variablePrototype()->end()
299 ->addDefaultsIfNotSet()
303 ->defaultValue($defaults['index']['route'])
304 ->scalarPrototype()->end()
307 ->addDefaultsIfNotSet()
309 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['index']['view']['name'])->end()
310 ->arrayNode('context')
312 ->defaultValue($defaults['index']['view']['context'])
313 ->variablePrototype()->end()
320 ->addDefaultsIfNotSet()
324 ->defaultValue($defaults['login']['route'])
325 ->scalarPrototype()->end()
328 ->addDefaultsIfNotSet()
330 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['login']['view']['name'])->end()
331 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['login']['view']['form'])->end()
332 ->arrayNode('context')
334 ->defaultValue($defaults['login']['view']['context'])
335 ->variablePrototype()->end()
341 ->arrayNode('recover')
342 ->addDefaultsIfNotSet()
346 ->defaultValue($defaults['recover']['route'])
347 ->scalarPrototype()->end()
350 ->addDefaultsIfNotSet()
352 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['name'])->end()
353 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['form'])->end()
354 ->arrayNode('context')
356 ->defaultValue($defaults['recover']['view']['context'])
357 ->variablePrototype()->end()
362 ->addDefaultsIfNotSet()
364 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['subject'])->end()
365 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['html'])->end()
366 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['text'])->end()
367 ->arrayNode('context')
369 ->defaultValue($defaults['recover']['mail']['context'])
370 ->variablePrototype()->end()
376 ->arrayNode('register')
377 ->addDefaultsIfNotSet()
381 ->defaultValue($defaults['edit']['admin'])
382 ->variablePrototype()->end()
386 ->defaultValue($defaults['register']['field'])
387 ->variablePrototype()->end()
391 ->defaultValue($defaults['register']['route'])
392 ->scalarPrototype()->end()
395 ->addDefaultsIfNotSet()
397 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
398 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
399 ->arrayNode('context')
401 ->defaultValue($defaults['register']['view']['context'])
402 ->variablePrototype()->end()
407 ->addDefaultsIfNotSet()
409 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['subject'])->end()
410 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['html'])->end()
411 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['text'])->end()
412 ->arrayNode('context')
414 ->defaultValue($defaults['register']['mail']['context'])
415 ->variablePrototype()->end()