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 'civility' => 'Mister',
47 'name' => 'rapsys_user_confirm',
51 'name' => 'rapsys_user_edit',
55 'name' => 'rapsys_user_index',
59 'name' => 'rapsys_user_login',
63 'name' => 'rapsys_user_recover',
67 'name' => 'rapsys_user_register',
72 'locales' => '%kernel.translator.fallbacks%',
77 'title' => 'John Doe',
78 'mail' => 'contact@example.com'
83 'route' => ['index' => 'index_url'],
85 'name' => '@RapsysUser/form/register.html.twig',
86 'edit' => 'Rapsys\UserBundle\Form\RegisterType',
87 'reset' => 'Rapsys\UserBundle\Form\LoginType',
92 'route' => ['index' => 'index_url'],
94 'name' => '@RapsysUser/form/login.html.twig',
95 'form' => 'Rapsys\UserBundle\Form\LoginType',
100 'route' => ['index' => 'index_url', 'recover' => 'recover_url'],
102 'name' => '@RapsysUser/form/recover.html.twig',
103 'form' => 'Rapsys\UserBundle\Form\LoginType',
107 'subject' => 'Welcome back!',
108 'html' => '@RapsysUser/mail/recover.html.twig',
109 'text' => '@RapsysUser/mail/recover.text.twig',
115 'route' => ['index' => 'index_url', 'confirm' => 'confirm_url'],
117 'name' => '@RapsysUser/form/register.html.twig',
118 'form' => 'Rapsys\UserBundle\Form\RegisterType',
122 'subject' => 'Welcome!',
123 'html' => '@RapsysUser/mail/register.html.twig',
124 'text' => '@RapsysUser/mail/register.text.twig',
131 * Defines parameters allowed to configure the bundle
133 * @link https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
134 * @link http://symfony.com/doc/current/components/config/definition.html
135 * @link https://github.com/symfony/assetic-bundle/blob/master/DependencyInjection/Configuration.php#L63
137 * @see php bin/console config:dump-reference rapsys_user to dump default config
138 * @see php bin/console debug:config rapsys_user to dump config
143 ->addDefaultsIfNotSet()
147 ->defaultValue($defaults['class'])
148 ->scalarPrototype()->end()
150 ->arrayNode('default')
152 ->defaultValue($defaults['default'])
153 ->variablePrototype()->end()
156 ->addDefaultsIfNotSet()
158 ->arrayNode('confirm')
159 ->addDefaultsIfNotSet()
161 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['confirm']['name'])->end()
162 ->arrayNode('context')
164 ->defaultValue($defaults['route']['confirm']['context'])
165 ->scalarPrototype()->end()
170 ->addDefaultsIfNotSet()
172 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['index']['name'])->end()
173 ->arrayNode('context')
175 ->defaultValue($defaults['route']['index']['context'])
176 ->scalarPrototype()->end()
181 ->addDefaultsIfNotSet()
183 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['edit']['name'])->end()
184 ->arrayNode('context')
186 ->defaultValue($defaults['route']['edit']['context'])
187 ->scalarPrototype()->end()
192 ->addDefaultsIfNotSet()
194 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['login']['name'])->end()
195 ->arrayNode('context')
197 ->defaultValue($defaults['route']['login']['context'])
198 ->scalarPrototype()->end()
202 ->arrayNode('recover')
203 ->addDefaultsIfNotSet()
205 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover']['name'])->end()
206 ->arrayNode('context')
208 ->defaultValue($defaults['route']['recover']['context'])
209 ->scalarPrototype()->end()
213 ->arrayNode('register')
214 ->addDefaultsIfNotSet()
216 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['register']['name'])->end()
217 ->arrayNode('context')
219 ->defaultValue($defaults['route']['register']['context'])
220 ->scalarPrototype()->end()
226 ->arrayNode('translate')
228 ->defaultValue($defaults['translate'])
229 ->scalarPrototype()->end()
231 #TODO: see if we can't prevent key normalisation with ->normalizeKeys(false)
232 ->scalarNode('locales')->cannotBeEmpty()->defaultValue($defaults['locales'])->end()
233 #TODO: see if we can't prevent key normalisation with ->normalizeKeys(false)
234 ->arrayNode('languages')
236 ->defaultValue($defaults['languages'])
237 ->scalarPrototype()->end()
239 ->arrayNode('contact')
240 ->addDefaultsIfNotSet()
242 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['contact']['title'])->end()
243 ->scalarNode('mail')->cannotBeEmpty()->defaultValue($defaults['contact']['mail'])->end()
246 ->arrayNode('context')
248 ->defaultValue($defaults['context'])
249 ->variablePrototype()->end()
252 ->addDefaultsIfNotSet()
256 ->defaultValue($defaults['edit']['field'])
257 ->variablePrototype()->end()
261 ->defaultValue($defaults['edit']['route'])
262 ->scalarPrototype()->end()
265 ->addDefaultsIfNotSet()
267 ->scalarNode('edit')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['edit'])->end()
268 ->scalarNode('reset')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['reset'])->end()
269 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['name'])->end()
270 ->arrayNode('context')
272 ->defaultValue($defaults['edit']['view']['context'])
273 ->variablePrototype()->end()
280 ->addDefaultsIfNotSet()
284 ->defaultValue($defaults['login']['route'])
285 ->scalarPrototype()->end()
288 ->addDefaultsIfNotSet()
290 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['login']['view']['name'])->end()
291 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['login']['view']['form'])->end()
292 ->arrayNode('context')
294 ->defaultValue($defaults['login']['view']['context'])
295 ->variablePrototype()->end()
301 ->arrayNode('recover')
302 ->addDefaultsIfNotSet()
306 ->defaultValue($defaults['recover']['route'])
307 ->scalarPrototype()->end()
310 ->addDefaultsIfNotSet()
312 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['name'])->end()
313 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['form'])->end()
314 ->arrayNode('context')
316 ->defaultValue($defaults['recover']['view']['context'])
317 ->variablePrototype()->end()
322 ->addDefaultsIfNotSet()
324 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['subject'])->end()
325 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['html'])->end()
326 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['text'])->end()
327 ->arrayNode('context')
329 ->defaultValue($defaults['recover']['mail']['context'])
330 ->variablePrototype()->end()
336 ->arrayNode('register')
337 ->addDefaultsIfNotSet()
341 ->defaultValue($defaults['register']['field'])
342 ->variablePrototype()->end()
346 ->defaultValue($defaults['register']['route'])
347 ->scalarPrototype()->end()
350 ->addDefaultsIfNotSet()
352 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
353 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
354 ->arrayNode('context')
356 ->defaultValue($defaults['register']['view']['context'])
357 ->variablePrototype()->end()
362 ->addDefaultsIfNotSet()
364 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['subject'])->end()
365 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['html'])->end()
366 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['text'])->end()
367 ->arrayNode('context')
369 ->defaultValue($defaults['register']['mail']['context'])
370 ->variablePrototype()->end()