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 ->scalarNode('locales')->cannotBeEmpty()->defaultValue($defaults['locales'])->end()
232 ->arrayNode('languages')
234 ->defaultValue($defaults['languages'])
235 ->scalarPrototype()->end()
237 ->arrayNode('contact')
238 ->addDefaultsIfNotSet()
240 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['contact']['title'])->end()
241 ->scalarNode('mail')->cannotBeEmpty()->defaultValue($defaults['contact']['mail'])->end()
244 ->arrayNode('context')
246 ->defaultValue($defaults['context'])
247 ->variablePrototype()->end()
250 ->addDefaultsIfNotSet()
254 ->defaultValue($defaults['edit']['field'])
255 ->variablePrototype()->end()
259 ->defaultValue($defaults['edit']['route'])
260 ->scalarPrototype()->end()
263 ->addDefaultsIfNotSet()
265 ->scalarNode('edit')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['edit'])->end()
266 ->scalarNode('reset')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['reset'])->end()
267 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['name'])->end()
268 ->arrayNode('context')
270 ->defaultValue($defaults['edit']['view']['context'])
271 ->variablePrototype()->end()
278 ->addDefaultsIfNotSet()
282 ->defaultValue($defaults['login']['route'])
283 ->scalarPrototype()->end()
286 ->addDefaultsIfNotSet()
288 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['login']['view']['name'])->end()
289 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['login']['view']['form'])->end()
290 ->arrayNode('context')
292 ->defaultValue($defaults['login']['view']['context'])
293 ->variablePrototype()->end()
299 ->arrayNode('recover')
300 ->addDefaultsIfNotSet()
304 ->defaultValue($defaults['recover']['route'])
305 ->scalarPrototype()->end()
308 ->addDefaultsIfNotSet()
310 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['name'])->end()
311 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['form'])->end()
312 ->arrayNode('context')
314 ->defaultValue($defaults['recover']['view']['context'])
315 ->variablePrototype()->end()
320 ->addDefaultsIfNotSet()
322 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['subject'])->end()
323 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['html'])->end()
324 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['text'])->end()
325 ->arrayNode('context')
327 ->defaultValue($defaults['recover']['mail']['context'])
328 ->variablePrototype()->end()
334 ->arrayNode('register')
335 ->addDefaultsIfNotSet()
339 ->defaultValue($defaults['register']['field'])
340 ->variablePrototype()->end()
344 ->defaultValue($defaults['register']['route'])
345 ->scalarPrototype()->end()
348 ->addDefaultsIfNotSet()
350 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
351 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
352 ->arrayNode('context')
354 ->defaultValue($defaults['register']['view']['context'])
355 ->variablePrototype()->end()
360 ->addDefaultsIfNotSet()
362 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['subject'])->end()
363 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['html'])->end()
364 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['text'])->end()
365 ->arrayNode('context')
367 ->defaultValue($defaults['register']['mail']['context'])
368 ->variablePrototype()->end()