1 <?php
declare(strict_types
=1);
4 * This file is part of the Rapsys PackBundle 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'
82 'route' => ['index' => 'index_url'],
84 'form' => 'Rapsys\UserBundle\Form\RegisterType',
85 'name' => '@RapsysUser/form/register.html.twig',
90 'route' => ['index' => 'index_url'],
92 'name' => '@RapsysUser/form/login.html.twig',
93 'form' => 'Rapsys\UserBundle\Form\LoginType',
98 'route' => ['index' => 'index_url', 'recover' => 'recover_url'],
100 'name' => '@RapsysUser/form/recover.html.twig',
101 'form' => 'Rapsys\UserBundle\Form\LoginType',
105 'subject' => 'Welcome back!',
106 'html' => '@RapsysUser/mail/recover.html.twig',
107 'text' => '@RapsysUser/mail/recover.text.twig',
112 'route' => ['index' => 'index_url', 'confirm' => 'confirm_url'],
114 'form' => 'Rapsys\UserBundle\Form\RegisterType',
115 'name' => '@RapsysUser/form/register.html.twig',
119 'subject' => 'Welcome!',
120 'html' => '@RapsysUser/mail/register.html.twig',
121 'text' => '@RapsysUser/mail/register.text.twig',
128 * Defines parameters allowed to configure the bundle
130 * @link https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
131 * @link http://symfony.com/doc/current/components/config/definition.html
132 * @link https://github.com/symfony/assetic-bundle/blob/master/DependencyInjection/Configuration.php#L63
134 * @see php bin/console config:dump-reference rapsys_user to dump default config
135 * @see php bin/console debug:config rapsys_user to dump config
140 ->addDefaultsIfNotSet()
144 ->defaultValue($defaults['class'])
145 ->scalarPrototype()->end()
147 ->arrayNode('default')
148 ->addDefaultsIfNotSet()
150 ->scalarNode('civility')->cannotBeEmpty()->defaultValue($defaults['default']['civility'])->end()
153 ->defaultValue($defaults['default']['group'])
154 ->scalarPrototype()->end()
159 ->addDefaultsIfNotSet()
161 ->arrayNode('confirm')
162 ->addDefaultsIfNotSet()
164 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['confirm']['name'])->end()
165 ->arrayNode('context')
167 ->defaultValue($defaults['route']['confirm']['context'])
168 ->scalarPrototype()->end()
173 ->addDefaultsIfNotSet()
175 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['index']['name'])->end()
176 ->arrayNode('context')
178 ->defaultValue($defaults['route']['index']['context'])
179 ->scalarPrototype()->end()
184 ->addDefaultsIfNotSet()
186 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['edit']['name'])->end()
187 ->arrayNode('context')
189 ->defaultValue($defaults['route']['edit']['context'])
190 ->scalarPrototype()->end()
195 ->addDefaultsIfNotSet()
197 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['login']['name'])->end()
198 ->arrayNode('context')
200 ->defaultValue($defaults['route']['login']['context'])
201 ->scalarPrototype()->end()
205 ->arrayNode('recover')
206 ->addDefaultsIfNotSet()
208 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover']['name'])->end()
209 ->arrayNode('context')
211 ->defaultValue($defaults['route']['recover']['context'])
212 ->scalarPrototype()->end()
216 ->arrayNode('register')
217 ->addDefaultsIfNotSet()
219 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['register']['name'])->end()
220 ->arrayNode('context')
222 ->defaultValue($defaults['route']['register']['context'])
223 ->scalarPrototype()->end()
229 ->arrayNode('translate')
231 ->defaultValue($defaults['translate'])
232 ->scalarPrototype()->end()
234 ->scalarNode('locales')->cannotBeEmpty()->defaultValue($defaults['locales'])->end()
235 ->arrayNode('languages')
237 ->defaultValue($defaults['languages'])
238 ->scalarPrototype()->end()
240 ->arrayNode('contact')
241 ->addDefaultsIfNotSet()
243 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['contact']['title'])->end()
244 ->scalarNode('mail')->cannotBeEmpty()->defaultValue($defaults['contact']['mail'])->end()
247 ->arrayNode('context')
249 ->defaultValue($defaults['context'])
250 ->variablePrototype()->end()
253 ->addDefaultsIfNotSet()
257 ->defaultValue($defaults['edit']['route'])
258 ->scalarPrototype()->end()
261 ->addDefaultsIfNotSet()
263 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['form'])->end()
264 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['name'])->end()
265 ->arrayNode('context')
267 ->defaultValue($defaults['edit']['view']['context'])
268 ->variablePrototype()->end()
275 ->addDefaultsIfNotSet()
279 ->defaultValue($defaults['login']['route'])
280 ->scalarPrototype()->end()
283 ->addDefaultsIfNotSet()
285 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['login']['view']['name'])->end()
286 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['login']['view']['form'])->end()
287 ->arrayNode('context')
289 ->defaultValue($defaults['login']['view']['context'])
290 ->variablePrototype()->end()
296 ->arrayNode('recover')
297 ->addDefaultsIfNotSet()
301 ->defaultValue($defaults['recover']['route'])
302 ->scalarPrototype()->end()
305 ->addDefaultsIfNotSet()
307 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['name'])->end()
308 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['form'])->end()
309 ->arrayNode('context')
311 ->defaultValue($defaults['recover']['view']['context'])
312 ->variablePrototype()->end()
317 ->addDefaultsIfNotSet()
319 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['subject'])->end()
320 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['html'])->end()
321 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['text'])->end()
322 ->arrayNode('context')
324 ->defaultValue($defaults['recover']['mail']['context'])
325 ->variablePrototype()->end()
331 ->arrayNode('register')
332 ->addDefaultsIfNotSet()
336 ->defaultValue($defaults['register']['route'])
337 ->scalarPrototype()->end()
340 ->addDefaultsIfNotSet()
342 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
343 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
344 ->arrayNode('context')
346 ->defaultValue($defaults['register']['view']['context'])
347 ->variablePrototype()->end()
352 ->addDefaultsIfNotSet()
354 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['subject'])->end()
355 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['html'])->end()
356 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['text'])->end()
357 ->arrayNode('context')
359 ->defaultValue($defaults['register']['mail']['context'])
360 ->variablePrototype()->end()