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',
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',
74 'address' => 'contact@example.com',
79 'admin' => ['mail' => true, 'pseudonym' => true],
81 'route' => ['index' => 'index_url'],
83 'name' => '@RapsysUser/form/register.html.twig',
84 'edit' => 'Rapsys\UserBundle\Form\EditType',
85 'reset' => 'Rapsys\UserBundle\Form\ResetType',
90 'route' => ['index' => 'index_url'],
92 'name' => '@RapsysUser/form/index.html.twig',
97 'route' => ['index' => 'index_url'],
99 'name' => '@RapsysUser/form/login.html.twig',
100 'form' => 'Rapsys\UserBundle\Form\LoginType',
105 'route' => ['index' => 'index_url', 'recover' => 'recover_url'],
107 'name' => '@RapsysUser/form/recover.html.twig',
108 'form' => 'Rapsys\UserBundle\Form\RecoverType',
112 'subject' => 'Welcome back!',
113 'html' => '@RapsysUser/mail/recover.html.twig',
114 'text' => '@RapsysUser/mail/recover.text.twig',
121 'route' => ['index' => 'index_url', 'confirm' => 'confirm_url'],
123 'name' => '@RapsysUser/form/register.html.twig',
124 'form' => 'Rapsys\UserBundle\Form\RegisterType',
128 'subject' => 'Welcome!',
129 'html' => '@RapsysUser/mail/register.html.twig',
130 'text' => '@RapsysUser/mail/register.text.twig',
137 * Defines parameters allowed to configure the bundle
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
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
149 ->addDefaultsIfNotSet()
152 ->addDefaultsIfNotSet()
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()
160 ->arrayNode('default')
161 ->addDefaultsIfNotSet()
164 ->scalarNode('admin')->cannotBeEmpty()->defaultValue($defaults['default']['admin'])->end()
165 ->scalarNode('civility')->cannotBeEmpty()->defaultValue($defaults['default']['civility'])->end()
168 ->defaultValue($defaults['default']['group'])
169 ->scalarPrototype()->end()
174 ->addDefaultsIfNotSet()
176 ->arrayNode('confirm')
177 ->addDefaultsIfNotSet()
179 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['confirm']['name'])->end()
180 ->arrayNode('context')
182 ->defaultValue($defaults['route']['confirm']['context'])
183 ->scalarPrototype()->end()
188 ->addDefaultsIfNotSet()
190 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['index']['name'])->end()
191 ->arrayNode('context')
193 ->defaultValue($defaults['route']['index']['context'])
194 ->scalarPrototype()->end()
199 ->addDefaultsIfNotSet()
201 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['edit']['name'])->end()
202 ->arrayNode('context')
204 ->defaultValue($defaults['route']['edit']['context'])
205 ->scalarPrototype()->end()
210 ->addDefaultsIfNotSet()
212 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['login']['name'])->end()
213 ->arrayNode('context')
215 ->defaultValue($defaults['route']['login']['context'])
216 ->scalarPrototype()->end()
220 ->arrayNode('recover')
221 ->addDefaultsIfNotSet()
223 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover']['name'])->end()
224 ->arrayNode('context')
226 ->defaultValue($defaults['route']['recover']['context'])
227 ->scalarPrototype()->end()
231 ->arrayNode('register')
232 ->addDefaultsIfNotSet()
234 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['register']['name'])->end()
235 ->arrayNode('context')
237 ->defaultValue($defaults['route']['register']['context'])
238 ->scalarPrototype()->end()
244 ->arrayNode('translate')
246 ->defaultValue($defaults['translate'])
247 ->scalarPrototype()->end()
249 ->arrayNode('contact')
250 ->addDefaultsIfNotSet()
252 ->scalarNode('address')->cannotBeEmpty()->defaultValue($defaults['contact']['address'])->end()
253 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['contact']['name'])->end()
256 ->arrayNode('context')
258 ->defaultValue($defaults['context'])
259 ->variablePrototype()->end()
262 ->addDefaultsIfNotSet()
266 ->defaultValue($defaults['edit']['admin'])
267 ->variablePrototype()->end()
271 ->defaultValue($defaults['edit']['field'])
272 ->variablePrototype()->end()
276 ->defaultValue($defaults['edit']['route'])
277 ->scalarPrototype()->end()
280 ->addDefaultsIfNotSet()
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')
287 ->defaultValue($defaults['edit']['view']['context'])
288 ->variablePrototype()->end()
295 ->addDefaultsIfNotSet()
299 ->defaultValue($defaults['index']['route'])
300 ->scalarPrototype()->end()
303 ->addDefaultsIfNotSet()
305 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['index']['view']['name'])->end()
306 ->arrayNode('context')
308 ->defaultValue($defaults['index']['view']['context'])
309 ->variablePrototype()->end()
316 ->addDefaultsIfNotSet()
320 ->defaultValue($defaults['login']['route'])
321 ->scalarPrototype()->end()
324 ->addDefaultsIfNotSet()
326 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['login']['view']['name'])->end()
327 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['login']['view']['form'])->end()
328 ->arrayNode('context')
330 ->defaultValue($defaults['login']['view']['context'])
331 ->variablePrototype()->end()
337 ->arrayNode('recover')
338 ->addDefaultsIfNotSet()
342 ->defaultValue($defaults['recover']['route'])
343 ->scalarPrototype()->end()
346 ->addDefaultsIfNotSet()
348 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['name'])->end()
349 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['form'])->end()
350 ->arrayNode('context')
352 ->defaultValue($defaults['recover']['view']['context'])
353 ->variablePrototype()->end()
358 ->addDefaultsIfNotSet()
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')
365 ->defaultValue($defaults['recover']['mail']['context'])
366 ->variablePrototype()->end()
372 ->arrayNode('register')
373 ->addDefaultsIfNotSet()
377 ->defaultValue($defaults['edit']['admin'])
378 ->variablePrototype()->end()
382 ->defaultValue($defaults['register']['field'])
383 ->variablePrototype()->end()
387 ->defaultValue($defaults['register']['route'])
388 ->scalarPrototype()->end()
391 ->addDefaultsIfNotSet()
393 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
394 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
395 ->arrayNode('context')
397 ->defaultValue($defaults['register']['view']['context'])
398 ->variablePrototype()->end()
403 ->addDefaultsIfNotSet()
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')
410 ->defaultValue($defaults['register']['mail']['context'])
411 ->variablePrototype()->end()