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 'name' => '@RapsysUser/form/register.html.twig',
85 'edit' => 'Rapsys\UserBundle\Form\RegisterType',
86 'reset' => 'Rapsys\UserBundle\Form\LoginType',
91 'route' => ['index' => 'index_url'],
93 'name' => '@RapsysUser/form/login.html.twig',
94 'form' => 'Rapsys\UserBundle\Form\LoginType',
99 'route' => ['index' => 'index_url', 'recover' => 'recover_url'],
101 'name' => '@RapsysUser/form/recover.html.twig',
102 'form' => 'Rapsys\UserBundle\Form\LoginType',
106 'subject' => 'Welcome back!',
107 'html' => '@RapsysUser/mail/recover.html.twig',
108 'text' => '@RapsysUser/mail/recover.text.twig',
113 'route' => ['index' => 'index_url', 'confirm' => 'confirm_url'],
115 'name' => '@RapsysUser/form/register.html.twig',
116 'form' => 'Rapsys\UserBundle\Form\RegisterType',
120 'subject' => 'Welcome!',
121 'html' => '@RapsysUser/mail/register.html.twig',
122 'text' => '@RapsysUser/mail/register.text.twig',
129 * Defines parameters allowed to configure the bundle
131 * @link https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
132 * @link http://symfony.com/doc/current/components/config/definition.html
133 * @link https://github.com/symfony/assetic-bundle/blob/master/DependencyInjection/Configuration.php#L63
135 * @see php bin/console config:dump-reference rapsys_user to dump default config
136 * @see php bin/console debug:config rapsys_user to dump config
141 ->addDefaultsIfNotSet()
145 ->defaultValue($defaults['class'])
146 ->scalarPrototype()->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('edit')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['edit'])->end()
265 ->scalarNode('reset')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['reset'])->end()
266 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['name'])->end()
267 ->arrayNode('context')
269 ->defaultValue($defaults['edit']['view']['context'])
270 ->variablePrototype()->end()
277 ->addDefaultsIfNotSet()
281 ->defaultValue($defaults['login']['route'])
282 ->scalarPrototype()->end()
285 ->addDefaultsIfNotSet()
287 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['login']['view']['name'])->end()
288 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['login']['view']['form'])->end()
289 ->arrayNode('context')
291 ->defaultValue($defaults['login']['view']['context'])
292 ->variablePrototype()->end()
298 ->arrayNode('recover')
299 ->addDefaultsIfNotSet()
303 ->defaultValue($defaults['recover']['route'])
304 ->scalarPrototype()->end()
307 ->addDefaultsIfNotSet()
309 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['name'])->end()
310 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['form'])->end()
311 ->arrayNode('context')
313 ->defaultValue($defaults['recover']['view']['context'])
314 ->variablePrototype()->end()
319 ->addDefaultsIfNotSet()
321 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['subject'])->end()
322 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['html'])->end()
323 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['text'])->end()
324 ->arrayNode('context')
326 ->defaultValue($defaults['recover']['mail']['context'])
327 ->variablePrototype()->end()
333 ->arrayNode('register')
334 ->addDefaultsIfNotSet()
338 ->defaultValue($defaults['register']['route'])
339 ->scalarPrototype()->end()
342 ->addDefaultsIfNotSet()
344 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
345 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
346 ->arrayNode('context')
348 ->defaultValue($defaults['register']['view']['context'])
349 ->variablePrototype()->end()
354 ->addDefaultsIfNotSet()
356 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['subject'])->end()
357 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['html'])->end()
358 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['text'])->end()
359 ->arrayNode('context')
361 ->defaultValue($defaults['register']['mail']['context'])
362 ->variablePrototype()->end()