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',
76 'title' => 'John Doe',
77 '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',
114 'route' => ['index' => 'index_url', 'confirm' => 'confirm_url'],
116 'name' => '@RapsysUser/form/register.html.twig',
117 'form' => 'Rapsys\UserBundle\Form\RegisterType',
121 'subject' => 'Welcome!',
122 'html' => '@RapsysUser/mail/register.html.twig',
123 'text' => '@RapsysUser/mail/register.text.twig',
130 * Defines parameters allowed to configure the bundle
132 * @link https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
133 * @link http://symfony.com/doc/current/components/config/definition.html
134 * @link https://github.com/symfony/assetic-bundle/blob/master/DependencyInjection/Configuration.php#L63
136 * @see php bin/console config:dump-reference rapsys_user to dump default config
137 * @see php bin/console debug:config rapsys_user to dump config
142 ->addDefaultsIfNotSet()
146 ->defaultValue($defaults['class'])
147 ->scalarPrototype()->end()
149 ->arrayNode('default')
151 ->defaultValue($defaults['default'])
152 ->variablePrototype()->end()
155 ->addDefaultsIfNotSet()
157 ->arrayNode('confirm')
158 ->addDefaultsIfNotSet()
160 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['confirm']['name'])->end()
161 ->arrayNode('context')
163 ->defaultValue($defaults['route']['confirm']['context'])
164 ->scalarPrototype()->end()
169 ->addDefaultsIfNotSet()
171 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['index']['name'])->end()
172 ->arrayNode('context')
174 ->defaultValue($defaults['route']['index']['context'])
175 ->scalarPrototype()->end()
180 ->addDefaultsIfNotSet()
182 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['edit']['name'])->end()
183 ->arrayNode('context')
185 ->defaultValue($defaults['route']['edit']['context'])
186 ->scalarPrototype()->end()
191 ->addDefaultsIfNotSet()
193 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['login']['name'])->end()
194 ->arrayNode('context')
196 ->defaultValue($defaults['route']['login']['context'])
197 ->scalarPrototype()->end()
201 ->arrayNode('recover')
202 ->addDefaultsIfNotSet()
204 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover']['name'])->end()
205 ->arrayNode('context')
207 ->defaultValue($defaults['route']['recover']['context'])
208 ->scalarPrototype()->end()
212 ->arrayNode('register')
213 ->addDefaultsIfNotSet()
215 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['register']['name'])->end()
216 ->arrayNode('context')
218 ->defaultValue($defaults['route']['register']['context'])
219 ->scalarPrototype()->end()
225 ->arrayNode('translate')
227 ->defaultValue($defaults['translate'])
228 ->scalarPrototype()->end()
230 #TODO: see if we can't prevent key normalisation with ->normalizeKeys(false)
231 ->arrayNode('languages')
233 ->defaultValue($defaults['languages'])
234 ->scalarPrototype()->end()
236 ->arrayNode('contact')
237 ->addDefaultsIfNotSet()
239 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['contact']['title'])->end()
240 ->scalarNode('mail')->cannotBeEmpty()->defaultValue($defaults['contact']['mail'])->end()
243 ->arrayNode('context')
245 ->defaultValue($defaults['context'])
246 ->variablePrototype()->end()
249 ->addDefaultsIfNotSet()
253 ->defaultValue($defaults['edit']['field'])
254 ->variablePrototype()->end()
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']['field'])
339 ->variablePrototype()->end()
343 ->defaultValue($defaults['register']['route'])
344 ->scalarPrototype()->end()
347 ->addDefaultsIfNotSet()
349 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
350 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
351 ->arrayNode('context')
353 ->defaultValue($defaults['register']['view']['context'])
354 ->variablePrototype()->end()
359 ->addDefaultsIfNotSet()
361 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['subject'])->end()
362 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['html'])->end()
363 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['text'])->end()
364 ->arrayNode('context')
366 ->defaultValue($defaults['register']['mail']['context'])
367 ->variablePrototype()->end()