]> Raphaƫl G. Git Repositories - userbundle/blob - DependencyInjection/Configuration.php
Fix requirement
[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 'homepage' => [
30 'name' => 'rapsys_user_homepage',
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 'view' => [
56 'name' => '@RapsysUser/form/login.html.twig',
57 'form' => 'Rapsys\UserBundle\Form\LoginType',
58 'context' => []
59 ]
60 ],
61 'recover' => [
62 'view' => [
63 'name' => '@RapsysUser/form/recover.html.twig',
64 'form' => 'Rapsys\UserBundle\Form\RecoverType',
65 'context' => []
66 ],
67 'mail' => [
68 'subject' => 'Welcome back!',
69 'html' => '@RapsysUser/mail/recover.html.twig',
70 'text' => '@RapsysUser/mail/recover.text.twig',
71 'route' => ['homepage' => 'homepage_url', 'recover_mail' => 'recover_url'],
72 'context' => []
73 ]
74 ],
75 'recover_mail' => [
76 'view' => [
77 'name' => '@RapsysUser/form/recover_mail.html.twig',
78 'form' => 'Rapsys\UserBundle\Form\RecoverMailType',
79 'context' => []
80 ],
81 'mail' => [
82 'subject' => 'Welcome back!',
83 'html' => '@RapsysUser/mail/recover_mail.html.twig',
84 'text' => '@RapsysUser/mail/recover_mail.text.twig',
85 'route' => ['homepage' => 'homepage_url'],
86 'context' => []
87 ]
88 ],
89 'register' => [
90 'view' => [
91 'form' => 'Rapsys\UserBundle\Form\RegisterType',
92 'name' => '@RapsysUser/form/register.html.twig',
93 'context' => []
94 ],
95 'mail' => [
96 'subject' => 'Welcome!',
97 'html' => '@RapsysUser/mail/register.html.twig',
98 'text' => '@RapsysUser/mail/register.text.twig',
99 'route' => ['homepage' => 'homepage_url'],
100 'context' => []
101 ]
102 ]
103 ];
104
105 //Here we define the parameters that are allowed to configure the bundle.
106 //TODO: see https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php for default value and description
107 //TODO: see http://symfony.com/doc/current/components/config/definition.html
108 //TODO: see fosuser DependencyInjection/Configuration.php
109 //XXX: use bin/console config:dump-reference to dump class infos
110
111 //Here we define the parameters that are allowed to configure the bundle.
112 $treeBuilder
113 //Parameters
114 ->getRootNode()
115 ->addDefaultsIfNotSet()
116 ->children()
117 ->arrayNode('class')
118 ->addDefaultsIfNotSet()
119 ->children()
120 ->scalarNode('group')->cannotBeEmpty()->defaultValue($defaults['class']['group'])->end()
121 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['class']['title'])->end()
122 ->scalarNode('user')->cannotBeEmpty()->defaultValue($defaults['class']['user'])->end()
123 ->end()
124 ->end()
125 ->arrayNode('route')
126 ->addDefaultsIfNotSet()
127 ->children()
128 ->arrayNode('homepage')
129 ->addDefaultsIfNotSet()
130 ->children()
131 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['homepage']['name'])->end()
132 ->arrayNode('context')
133 ->treatNullLike(array())
134 ->defaultValue($defaults['route']['homepage']['context'])
135 ->scalarPrototype()->end()
136 ->end()
137 ->end()
138 ->end()
139 ->arrayNode('login')
140 ->addDefaultsIfNotSet()
141 ->children()
142 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['login']['name'])->end()
143 ->arrayNode('context')
144 ->treatNullLike(array())
145 ->defaultValue($defaults['route']['login']['context'])
146 ->scalarPrototype()->end()
147 ->end()
148 ->end()
149 ->end()
150 ->arrayNode('recover')
151 ->addDefaultsIfNotSet()
152 ->children()
153 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover']['name'])->end()
154 ->arrayNode('context')
155 ->treatNullLike(array())
156 ->defaultValue($defaults['route']['recover']['context'])
157 ->scalarPrototype()->end()
158 ->end()
159 ->end()
160 ->end()
161 ->arrayNode('recover_mail')
162 ->addDefaultsIfNotSet()
163 ->children()
164 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover_mail']['name'])->end()
165 ->arrayNode('context')
166 ->treatNullLike(array())
167 ->defaultValue($defaults['route']['recover_mail']['context'])
168 ->scalarPrototype()->end()
169 ->end()
170 ->end()
171 ->end()
172 ->arrayNode('register')
173 ->addDefaultsIfNotSet()
174 ->children()
175 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['register']['name'])->end()
176 ->arrayNode('context')
177 ->treatNullLike(array())
178 ->defaultValue($defaults['route']['register']['context'])
179 ->scalarPrototype()->end()
180 ->end()
181 ->end()
182 ->end()
183 ->end()
184 ->end()
185 ->arrayNode('contact')
186 ->addDefaultsIfNotSet()
187 ->children()
188 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['contact']['name'])->end()
189 ->scalarNode('mail')->cannotBeEmpty()->defaultValue($defaults['contact']['mail'])->end()
190 ->end()
191 ->end()
192 ->arrayNode('login')
193 ->addDefaultsIfNotSet()
194 ->children()
195 ->arrayNode('view')
196 ->addDefaultsIfNotSet()
197 ->children()
198 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['login']['view']['name'])->end()
199 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['login']['view']['form'])->end()
200 ->arrayNode('context')
201 ->treatNullLike(array())
202 ->defaultValue($defaults['login']['view']['context'])
203 ->scalarPrototype()->end()
204 ->end()
205 ->end()
206 ->end()
207 ->end()
208 ->end()
209 ->arrayNode('recover')
210 ->addDefaultsIfNotSet()
211 ->children()
212 ->arrayNode('view')
213 ->addDefaultsIfNotSet()
214 ->children()
215 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['name'])->end()
216 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['form'])->end()
217 ->arrayNode('context')
218 ->treatNullLike(array())
219 ->defaultValue($defaults['recover']['view']['context'])
220 ->scalarPrototype()->end()
221 ->end()
222 ->end()
223 ->end()
224 ->arrayNode('mail')
225 ->addDefaultsIfNotSet()
226 ->children()
227 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['subject'])->end()
228 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['html'])->end()
229 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['text'])->end()
230 ->arrayNode('route')
231 ->treatNullLike(array())
232 ->defaultValue($defaults['recover']['mail']['route'])
233 ->scalarPrototype()->end()
234 ->end()
235 ->arrayNode('context')
236 ->treatNullLike(array())
237 ->defaultValue($defaults['recover']['mail']['context'])
238 ->scalarPrototype()->end()
239 ->end()
240 ->end()
241 ->end()
242 ->end()
243 ->end()
244 ->arrayNode('recover_mail')
245 ->addDefaultsIfNotSet()
246 ->children()
247 ->arrayNode('view')
248 ->addDefaultsIfNotSet()
249 ->children()
250 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover_mail']['view']['name'])->end()
251 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover_mail']['view']['form'])->end()
252 ->arrayNode('context')
253 ->treatNullLike(array())
254 ->defaultValue($defaults['recover_mail']['view']['context'])
255 ->scalarPrototype()->end()
256 ->end()
257 ->end()
258 ->end()
259 ->arrayNode('mail')
260 ->addDefaultsIfNotSet()
261 ->children()
262 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover_mail']['mail']['subject'])->end()
263 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover_mail']['mail']['html'])->end()
264 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover_mail']['mail']['text'])->end()
265 ->arrayNode('route')
266 ->treatNullLike(array())
267 ->defaultValue($defaults['recover_mail']['mail']['route'])
268 ->scalarPrototype()->end()
269 ->end()
270 ->arrayNode('context')
271 ->treatNullLike(array())
272 ->defaultValue($defaults['recover_mail']['mail']['context'])
273 ->scalarPrototype()->end()
274 ->end()
275 ->end()
276 ->end()
277 ->end()
278 ->end()
279 ->arrayNode('register')
280 ->addDefaultsIfNotSet()
281 ->children()
282 ->arrayNode('view')
283 ->addDefaultsIfNotSet()
284 ->children()
285 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
286 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
287 ->arrayNode('context')
288 ->treatNullLike(array())
289 ->defaultValue($defaults['register']['view']['context'])
290 ->scalarPrototype()->end()
291 ->end()
292 ->end()
293 ->end()
294 ->arrayNode('mail')
295 ->addDefaultsIfNotSet()
296 ->children()
297 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['subject'])->end()
298 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['html'])->end()
299 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['text'])->end()
300 ->arrayNode('route')
301 ->treatNullLike(array())
302 ->defaultValue($defaults['register']['mail']['route'])
303 ->scalarPrototype()->end()
304 ->end()
305 ->arrayNode('context')
306 ->treatNullLike(array())
307 ->defaultValue($defaults['register']['mail']['context'])
308 ->scalarPrototype()->end()
309 ->end()
310 ->end()
311 ->end()
312 ->end()
313 ->end()
314 ->end()
315 ->end();
316
317 return $treeBuilder;
318 }
319 }