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
;
18 * This is the class that validates and merges configuration from your app/config files.
20 * @link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
24 class Configuration
implements ConfigurationInterface
{
28 public function getConfigTreeBuilder(): TreeBuilder
{
30 $treeBuilder = new TreeBuilder('rapsys_user');
32 //The bundle default values
35 'group' => 'Rapsys\\UserBundle\\Entity\\Group',
36 'civility' => 'Rapsys\\UserBundle\\Entity\\Civility',
37 'user' => 'Rapsys\\UserBundle\\Entity\\User'
40 'civility' => 'Mister',
45 'name' => 'rapsys_user_confirm',
49 'name' => 'rapsys_user_edit',
53 'name' => 'rapsys_user_index',
57 'name' => 'rapsys_user_login',
61 'name' => 'rapsys_user_recover',
65 'name' => 'rapsys_user_register',
70 'locales' => '%kernel.translator.fallbacks%',
75 'title' => 'John Doe',
76 'mail' => 'contact@example.com'
80 'route' => ['index' => 'index_url'],
82 'form' => 'Rapsys\UserBundle\Form\RegisterType',
83 'name' => '@RapsysUser/form/register.html.twig',
88 'route' => ['index' => 'index_url'],
90 'name' => '@RapsysUser/form/login.html.twig',
91 'form' => 'Rapsys\UserBundle\Form\LoginType',
96 'route' => ['index' => 'index_url', 'recover' => 'recover_url'],
98 'name' => '@RapsysUser/form/recover.html.twig',
99 'form' => 'Rapsys\UserBundle\Form\RecoverType',
103 'subject' => 'Welcome back!',
104 'html' => '@RapsysUser/mail/recover.html.twig',
105 'text' => '@RapsysUser/mail/recover.text.twig',
110 'route' => ['index' => 'index_url', 'confirm' => 'confirm_url'],
112 'form' => 'Rapsys\UserBundle\Form\RegisterType',
113 'name' => '@RapsysUser/form/register.html.twig',
117 'subject' => 'Welcome!',
118 'html' => '@RapsysUser/mail/register.html.twig',
119 'text' => '@RapsysUser/mail/register.text.twig',
126 * Defines parameters allowed to configure the bundle
128 * @link https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
129 * @link http://symfony.com/doc/current/components/config/definition.html
130 * @link https://github.com/symfony/assetic-bundle/blob/master/DependencyInjection/Configuration.php#L63
132 * @see php bin/console config:dump-reference rapsys_user to dump default config
133 * @see php bin/console debug:config rapsys_user to dump config
138 ->addDefaultsIfNotSet()
141 ->addDefaultsIfNotSet()
143 ->scalarNode('group')->cannotBeEmpty()->defaultValue($defaults['class']['group'])->end()
144 ->scalarNode('civility')->cannotBeEmpty()->defaultValue($defaults['class']['civility'])->end()
145 ->scalarNode('user')->cannotBeEmpty()->defaultValue($defaults['class']['user'])->end()
148 ->arrayNode('default')
149 ->addDefaultsIfNotSet()
151 ->scalarNode('civility')->cannotBeEmpty()->defaultValue($defaults['default']['civility'])->end()
154 ->defaultValue($defaults['default']['group'])
155 ->scalarPrototype()->end()
160 ->addDefaultsIfNotSet()
162 ->arrayNode('confirm')
163 ->addDefaultsIfNotSet()
165 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['confirm']['name'])->end()
166 ->arrayNode('context')
168 ->defaultValue($defaults['route']['confirm']['context'])
169 ->scalarPrototype()->end()
174 ->addDefaultsIfNotSet()
176 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['index']['name'])->end()
177 ->arrayNode('context')
179 ->defaultValue($defaults['route']['index']['context'])
180 ->scalarPrototype()->end()
185 ->addDefaultsIfNotSet()
187 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['edit']['name'])->end()
188 ->arrayNode('context')
190 ->defaultValue($defaults['route']['edit']['context'])
191 ->scalarPrototype()->end()
196 ->addDefaultsIfNotSet()
198 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['login']['name'])->end()
199 ->arrayNode('context')
201 ->defaultValue($defaults['route']['login']['context'])
202 ->scalarPrototype()->end()
206 ->arrayNode('recover')
207 ->addDefaultsIfNotSet()
209 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover']['name'])->end()
210 ->arrayNode('context')
212 ->defaultValue($defaults['route']['recover']['context'])
213 ->scalarPrototype()->end()
217 ->arrayNode('register')
218 ->addDefaultsIfNotSet()
220 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['register']['name'])->end()
221 ->arrayNode('context')
223 ->defaultValue($defaults['route']['register']['context'])
224 ->scalarPrototype()->end()
230 ->arrayNode('translate')
232 ->defaultValue($defaults['translate'])
233 ->scalarPrototype()->end()
235 ->scalarNode('locales')->cannotBeEmpty()->defaultValue($defaults['locales'])->end()
236 ->arrayNode('languages')
238 ->defaultValue($defaults['languages'])
239 ->scalarPrototype()->end()
241 ->arrayNode('contact')
242 ->addDefaultsIfNotSet()
244 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['contact']['title'])->end()
245 ->scalarNode('mail')->cannotBeEmpty()->defaultValue($defaults['contact']['mail'])->end()
248 ->arrayNode('context')
250 ->defaultValue($defaults['context'])
251 ->variablePrototype()->end()
254 ->addDefaultsIfNotSet()
258 ->defaultValue($defaults['edit']['route'])
259 ->scalarPrototype()->end()
262 ->addDefaultsIfNotSet()
264 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['form'])->end()
265 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['name'])->end()
266 ->arrayNode('context')
268 ->defaultValue($defaults['edit']['view']['context'])
269 ->variablePrototype()->end()
276 ->addDefaultsIfNotSet()
280 ->defaultValue($defaults['login']['route'])
281 ->scalarPrototype()->end()
284 ->addDefaultsIfNotSet()
286 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['login']['view']['name'])->end()
287 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['login']['view']['form'])->end()
288 ->arrayNode('context')
290 ->defaultValue($defaults['login']['view']['context'])
291 ->variablePrototype()->end()
297 ->arrayNode('recover')
298 ->addDefaultsIfNotSet()
302 ->defaultValue($defaults['recover']['route'])
303 ->scalarPrototype()->end()
306 ->addDefaultsIfNotSet()
308 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['name'])->end()
309 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['form'])->end()
310 ->arrayNode('context')
312 ->defaultValue($defaults['recover']['view']['context'])
313 ->variablePrototype()->end()
318 ->addDefaultsIfNotSet()
320 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['subject'])->end()
321 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['html'])->end()
322 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['text'])->end()
323 ->arrayNode('context')
325 ->defaultValue($defaults['recover']['mail']['context'])
326 ->variablePrototype()->end()
332 ->arrayNode('register')
333 ->addDefaultsIfNotSet()
337 ->defaultValue($defaults['register']['route'])
338 ->scalarPrototype()->end()
341 ->addDefaultsIfNotSet()
343 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
344 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
345 ->arrayNode('context')
347 ->defaultValue($defaults['register']['view']['context'])
348 ->variablePrototype()->end()
353 ->addDefaultsIfNotSet()
355 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['subject'])->end()
356 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['html'])->end()
357 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['text'])->end()
358 ->arrayNode('context')
360 ->defaultValue($defaults['register']['mail']['context'])
361 ->variablePrototype()->end()