]> Raphaƫl G. Git Repositories - userbundle/blob - DependencyInjection/Configuration.php
Replace service Rapsys\UserBundle\Utils\Slugger with alias rapsys.slugger
[userbundle] / DependencyInjection / Configuration.php
1 <?php
2
3 namespace Rapsys\UserBundle\DependencyInjection;
4
5 use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6 use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8 /**
9 * This is the class that validates and merges configuration from your app/config files.
10 *
11 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
12 */
13 class Configuration implements ConfigurationInterface {
14 /**
15 * {@inheritdoc}
16 */
17 public function getConfigTreeBuilder() {
18 //Set tree builder
19 $treeBuilder = new TreeBuilder('rapsys_user');
20
21 //The bundle default values
22 $defaults = [
23 'class' => [
24 'group' => 'Rapsys\\UserBundle\\Entity\\Group',
25 'title' => 'Rapsys\\UserBundle\\Entity\\Title',
26 'user' => 'Rapsys\\UserBundle\\Entity\\User'
27 ],
28 'route' => [
29 'index' => [
30 'name' => 'rapsys_user_index',
31 'context' => []
32 ],
33 'login' => [
34 'name' => 'rapsys_user_login',
35 'context' => []
36 ],
37 'recover' => [
38 'name' => 'rapsys_user_recover',
39 'context' => []
40 ],
41 'recover_mail' => [
42 'name' => 'rapsys_user_recover_mail',
43 'context' => []
44 ],
45 'register' => [
46 'name' => 'rapsys_user_register',
47 'context' => []
48 ]
49 ],
50 'contact' => [
51 'name' => 'John Doe',
52 'mail' => 'contact@example.com'
53 ],
54 'login' => [
55 'route' => ['index' => 'index_url'],
56 'view' => [
57 'name' => '@RapsysUser/form/login.html.twig',
58 'form' => 'Rapsys\UserBundle\Form\LoginType',
59 'context' => []
60 ]
61 ],
62 'recover' => [
63 'route' => ['index' => 'index_url', 'recover_mail' => 'recover_url'],
64 'view' => [
65 'name' => '@RapsysUser/form/recover.html.twig',
66 'form' => 'Rapsys\UserBundle\Form\RecoverType',
67 'context' => []
68 ],
69 'mail' => [
70 'subject' => 'Welcome back!',
71 'html' => '@RapsysUser/mail/recover.html.twig',
72 'text' => '@RapsysUser/mail/recover.text.twig',
73 'context' => []
74 ]
75 ],
76 'recover_mail' => [
77 'route' => ['index' => 'index_url', 'recover_mail' => 'recover_url'],
78 'view' => [
79 'name' => '@RapsysUser/form/recover_mail.html.twig',
80 'form' => 'Rapsys\UserBundle\Form\RecoverMailType',
81 'context' => []
82 ],
83 'mail' => [
84 'subject' => 'Welcome back!',
85 'html' => '@RapsysUser/mail/recover_mail.html.twig',
86 'text' => '@RapsysUser/mail/recover_mail.text.twig',
87 'context' => []
88 ]
89 ],
90 'register' => [
91 'route' => ['index' => 'index_url'],
92 'view' => [
93 'form' => 'Rapsys\UserBundle\Form\RegisterType',
94 'name' => '@RapsysUser/form/register.html.twig',
95 'context' => []
96 ],
97 'mail' => [
98 'subject' => 'Welcome!',
99 'html' => '@RapsysUser/mail/register.html.twig',
100 'text' => '@RapsysUser/mail/register.text.twig',
101 'context' => []
102 ]
103 ]
104 ];
105
106 //Here we define the parameters that are allowed to configure the bundle.
107 //TODO: see https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php for default value and description
108 //TODO: see http://symfony.com/doc/current/components/config/definition.html
109 //TODO: see fosuser DependencyInjection/Configuration.php
110 //XXX: use bin/console config:dump-reference to dump class infos
111
112 //Here we define the parameters that are allowed to configure the bundle.
113 $treeBuilder
114 //Parameters
115 ->getRootNode()
116 ->addDefaultsIfNotSet()
117 ->children()
118 ->arrayNode('class')
119 ->addDefaultsIfNotSet()
120 ->children()
121 ->scalarNode('group')->cannotBeEmpty()->defaultValue($defaults['class']['group'])->end()
122 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['class']['title'])->end()
123 ->scalarNode('user')->cannotBeEmpty()->defaultValue($defaults['class']['user'])->end()
124 ->end()
125 ->end()
126 ->arrayNode('route')
127 ->addDefaultsIfNotSet()
128 ->children()
129 ->arrayNode('index')
130 ->addDefaultsIfNotSet()
131 ->children()
132 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['index']['name'])->end()
133 ->arrayNode('context')
134 ->treatNullLike(array())
135 ->defaultValue($defaults['route']['index']['context'])
136 ->scalarPrototype()->end()
137 ->end()
138 ->end()
139 ->end()
140 ->arrayNode('login')
141 ->addDefaultsIfNotSet()
142 ->children()
143 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['login']['name'])->end()
144 ->arrayNode('context')
145 ->treatNullLike(array())
146 ->defaultValue($defaults['route']['login']['context'])
147 ->scalarPrototype()->end()
148 ->end()
149 ->end()
150 ->end()
151 ->arrayNode('recover')
152 ->addDefaultsIfNotSet()
153 ->children()
154 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover']['name'])->end()
155 ->arrayNode('context')
156 ->treatNullLike(array())
157 ->defaultValue($defaults['route']['recover']['context'])
158 ->scalarPrototype()->end()
159 ->end()
160 ->end()
161 ->end()
162 ->arrayNode('recover_mail')
163 ->addDefaultsIfNotSet()
164 ->children()
165 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover_mail']['name'])->end()
166 ->arrayNode('context')
167 ->treatNullLike(array())
168 ->defaultValue($defaults['route']['recover_mail']['context'])
169 ->scalarPrototype()->end()
170 ->end()
171 ->end()
172 ->end()
173 ->arrayNode('register')
174 ->addDefaultsIfNotSet()
175 ->children()
176 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['register']['name'])->end()
177 ->arrayNode('context')
178 ->treatNullLike(array())
179 ->defaultValue($defaults['route']['register']['context'])
180 ->scalarPrototype()->end()
181 ->end()
182 ->end()
183 ->end()
184 ->end()
185 ->end()
186 ->arrayNode('contact')
187 ->addDefaultsIfNotSet()
188 ->children()
189 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['contact']['name'])->end()
190 ->scalarNode('mail')->cannotBeEmpty()->defaultValue($defaults['contact']['mail'])->end()
191 ->end()
192 ->end()
193 ->arrayNode('login')
194 ->addDefaultsIfNotSet()
195 ->children()
196 ->arrayNode('route')
197 ->treatNullLike(array())
198 ->defaultValue($defaults['login']['route'])
199 ->scalarPrototype()->end()
200 ->end()
201 ->arrayNode('view')
202 ->addDefaultsIfNotSet()
203 ->children()
204 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['login']['view']['name'])->end()
205 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['login']['view']['form'])->end()
206 ->arrayNode('context')
207 ->treatNullLike(array())
208 ->defaultValue($defaults['login']['view']['context'])
209 ->variablePrototype()->end()
210 ->end()
211 ->end()
212 ->end()
213 ->end()
214 ->end()
215 ->arrayNode('recover')
216 ->addDefaultsIfNotSet()
217 ->children()
218 ->arrayNode('route')
219 ->treatNullLike(array())
220 ->defaultValue($defaults['recover']['route'])
221 ->scalarPrototype()->end()
222 ->end()
223 ->arrayNode('view')
224 ->addDefaultsIfNotSet()
225 ->children()
226 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['name'])->end()
227 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['form'])->end()
228 ->arrayNode('context')
229 ->treatNullLike(array())
230 ->defaultValue($defaults['recover']['view']['context'])
231 ->variablePrototype()->end()
232 ->end()
233 ->end()
234 ->end()
235 ->arrayNode('mail')
236 ->addDefaultsIfNotSet()
237 ->children()
238 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['subject'])->end()
239 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['html'])->end()
240 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['text'])->end()
241 ->arrayNode('context')
242 ->treatNullLike(array())
243 ->defaultValue($defaults['recover']['mail']['context'])
244 ->variablePrototype()->end()
245 ->end()
246 ->end()
247 ->end()
248 ->end()
249 ->end()
250 ->arrayNode('recover_mail')
251 ->addDefaultsIfNotSet()
252 ->children()
253 ->arrayNode('route')
254 ->treatNullLike(array())
255 ->defaultValue($defaults['recover_mail']['route'])
256 ->scalarPrototype()->end()
257 ->end()
258 ->arrayNode('view')
259 ->addDefaultsIfNotSet()
260 ->children()
261 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover_mail']['view']['name'])->end()
262 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover_mail']['view']['form'])->end()
263 ->arrayNode('context')
264 ->treatNullLike(array())
265 ->defaultValue($defaults['recover_mail']['view']['context'])
266 ->variablePrototype()->end()
267 ->end()
268 ->end()
269 ->end()
270 ->arrayNode('mail')
271 ->addDefaultsIfNotSet()
272 ->children()
273 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover_mail']['mail']['subject'])->end()
274 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover_mail']['mail']['html'])->end()
275 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover_mail']['mail']['text'])->end()
276 ->arrayNode('context')
277 ->treatNullLike(array())
278 ->defaultValue($defaults['recover_mail']['mail']['context'])
279 ->variablePrototype()->end()
280 ->end()
281 ->end()
282 ->end()
283 ->end()
284 ->end()
285 ->arrayNode('register')
286 ->addDefaultsIfNotSet()
287 ->children()
288 ->arrayNode('route')
289 ->treatNullLike(array())
290 ->defaultValue($defaults['register']['route'])
291 ->scalarPrototype()->end()
292 ->end()
293 ->arrayNode('view')
294 ->addDefaultsIfNotSet()
295 ->children()
296 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
297 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
298 ->arrayNode('context')
299 ->treatNullLike(array())
300 ->defaultValue($defaults['register']['view']['context'])
301 ->variablePrototype()->end()
302 ->end()
303 ->end()
304 ->end()
305 ->arrayNode('mail')
306 ->addDefaultsIfNotSet()
307 ->children()
308 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['subject'])->end()
309 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['html'])->end()
310 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['text'])->end()
311 ->arrayNode('context')
312 ->treatNullLike(array())
313 ->defaultValue($defaults['register']['mail']['context'])
314 ->variablePrototype()->end()
315 ->end()
316 ->end()
317 ->end()
318 ->end()
319 ->end()
320 ->end()
321 ->end();
322
323 return $treeBuilder;
324 }
325 }