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')
151 ->addDefaultsIfNotSet()
153 ->scalarNode('civility')->cannotBeEmpty()->defaultValue($defaults['default']['civility'])->end()
156 ->defaultValue($defaults['default']['group'])
157 ->scalarPrototype()->end()
162 ->addDefaultsIfNotSet()
164 ->arrayNode('confirm')
165 ->addDefaultsIfNotSet()
167 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['confirm']['name'])->end()
168 ->arrayNode('context')
170 ->defaultValue($defaults['route']['confirm']['context'])
171 ->scalarPrototype()->end()
176 ->addDefaultsIfNotSet()
178 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['index']['name'])->end()
179 ->arrayNode('context')
181 ->defaultValue($defaults['route']['index']['context'])
182 ->scalarPrototype()->end()
187 ->addDefaultsIfNotSet()
189 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['edit']['name'])->end()
190 ->arrayNode('context')
192 ->defaultValue($defaults['route']['edit']['context'])
193 ->scalarPrototype()->end()
198 ->addDefaultsIfNotSet()
200 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['login']['name'])->end()
201 ->arrayNode('context')
203 ->defaultValue($defaults['route']['login']['context'])
204 ->scalarPrototype()->end()
208 ->arrayNode('recover')
209 ->addDefaultsIfNotSet()
211 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover']['name'])->end()
212 ->arrayNode('context')
214 ->defaultValue($defaults['route']['recover']['context'])
215 ->scalarPrototype()->end()
219 ->arrayNode('register')
220 ->addDefaultsIfNotSet()
222 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['register']['name'])->end()
223 ->arrayNode('context')
225 ->defaultValue($defaults['route']['register']['context'])
226 ->scalarPrototype()->end()
232 ->arrayNode('translate')
234 ->defaultValue($defaults['translate'])
235 ->scalarPrototype()->end()
237 ->scalarNode('locales')->cannotBeEmpty()->defaultValue($defaults['locales'])->end()
238 ->arrayNode('languages')
240 ->defaultValue($defaults['languages'])
241 ->scalarPrototype()->end()
243 ->arrayNode('contact')
244 ->addDefaultsIfNotSet()
246 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['contact']['title'])->end()
247 ->scalarNode('mail')->cannotBeEmpty()->defaultValue($defaults['contact']['mail'])->end()
250 ->arrayNode('context')
252 ->defaultValue($defaults['context'])
253 ->variablePrototype()->end()
256 ->addDefaultsIfNotSet()
260 ->defaultValue($defaults['edit']['field'])
261 ->variablePrototype()->end()
265 ->defaultValue($defaults['edit']['route'])
266 ->scalarPrototype()->end()
269 ->addDefaultsIfNotSet()
271 ->scalarNode('edit')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['edit'])->end()
272 ->scalarNode('reset')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['reset'])->end()
273 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['name'])->end()
274 ->arrayNode('context')
276 ->defaultValue($defaults['edit']['view']['context'])
277 ->variablePrototype()->end()
284 ->addDefaultsIfNotSet()
288 ->defaultValue($defaults['login']['route'])
289 ->scalarPrototype()->end()
292 ->addDefaultsIfNotSet()
294 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['login']['view']['name'])->end()
295 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['login']['view']['form'])->end()
296 ->arrayNode('context')
298 ->defaultValue($defaults['login']['view']['context'])
299 ->variablePrototype()->end()
305 ->arrayNode('recover')
306 ->addDefaultsIfNotSet()
310 ->defaultValue($defaults['recover']['route'])
311 ->scalarPrototype()->end()
314 ->addDefaultsIfNotSet()
316 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['name'])->end()
317 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['form'])->end()
318 ->arrayNode('context')
320 ->defaultValue($defaults['recover']['view']['context'])
321 ->variablePrototype()->end()
326 ->addDefaultsIfNotSet()
328 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['subject'])->end()
329 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['html'])->end()
330 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['text'])->end()
331 ->arrayNode('context')
333 ->defaultValue($defaults['recover']['mail']['context'])
334 ->variablePrototype()->end()
340 ->arrayNode('register')
341 ->addDefaultsIfNotSet()
345 ->defaultValue($defaults['register']['field'])
346 ->variablePrototype()->end()
350 ->defaultValue($defaults['register']['route'])
351 ->scalarPrototype()->end()
354 ->addDefaultsIfNotSet()
356 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
357 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
358 ->arrayNode('context')
360 ->defaultValue($defaults['register']['view']['context'])
361 ->variablePrototype()->end()
366 ->addDefaultsIfNotSet()
368 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['subject'])->end()
369 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['html'])->end()
370 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['text'])->end()
371 ->arrayNode('context')
373 ->defaultValue($defaults['register']['mail']['context'])
374 ->variablePrototype()->end()