Completed
Pull Request — master (#354)
by David de
06:18
created

Configuration::addCacheableResponseSection()   B

Complexity

Conditions 2
Paths 1

Size

Total Lines 30
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 26
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 30
ccs 26
cts 26
cp 1
rs 8.8571
cc 2
eloc 26
nc 1
nop 1
crap 2
1
<?php
2
3
/*
4
 * This file is part of the FOSHttpCacheBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\HttpCacheBundle\DependencyInjection;
13
14
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
15
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
16
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
17
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
18
use Symfony\Component\Config\Definition\ConfigurationInterface;
19
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
20
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
21
22
/**
23
 * This class contains the configuration information for the bundle.
24
 *
25
 * This information is solely responsible for how the different configuration
26
 * sections are normalized, and merged.
27
 *
28
 * @author David de Boer <[email protected]>
29
 * @author David Buchmann <[email protected]>
30
 */
31
class Configuration implements ConfigurationInterface
32
{
33
    /**
34
     * @var bool
35
     */
36
    private $debug;
37
38
    /**
39
     * @param bool $debug Whether to use the debug mode
40
     */
41 36
    public function __construct($debug)
42
    {
43 36
        $this->debug = $debug;
44 36
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 36
    public function getConfigTreeBuilder()
50
    {
51 36
        $treeBuilder = new TreeBuilder();
52 36
        $rootNode = $treeBuilder->root('fos_http_cache');
53
54
        $rootNode
55 36
            ->validate()
56
                ->ifTrue(function ($v) {
57 35
                    return $v['cache_manager']['enabled']
58 35
                        && !isset($v['proxy_client'])
59 35
                        && !isset($v['cache_manager']['custom_proxy_client'])
60
                    ;
61 36
                })
62
                ->then(function ($v) {
63 9
                    if ('auto' === $v['cache_manager']['enabled']) {
64 8
                        $v['cache_manager']['enabled'] = false;
65
66 8
                        return $v;
67
                    }
68 1
                    throw new InvalidConfigurationException('You need to configure a proxy_client or specify a custom_proxy_client to use the cache_manager.');
69 36
                })
70 36
            ->end()
71 36
            ->validate()
72
                ->ifTrue(function ($v) {
73 34
                    return $v['tags']['enabled'] && !$v['cache_manager']['enabled'];
74 36
                })
75
                ->then(function ($v) {
76 10
                    if ('auto' === $v['tags']['enabled']) {
77 9
                        $v['tags']['enabled'] = false;
78
79 9
                        return $v;
80
                    }
81 1
                    throw new InvalidConfigurationException('You need to configure a proxy_client to get the cache_manager needed for tag handling.');
82 36
                })
83 36
            ->end()
84 36
            ->validate()
85
                ->ifTrue(function ($v) {
86 33
                    return $v['invalidation']['enabled'] && !$v['cache_manager']['enabled'];
87 36
                })
88
                ->then(function ($v) {
89 9
                    if ('auto' === $v['invalidation']['enabled']) {
90 8
                        $v['invalidation']['enabled'] = false;
91
92 8
                        return $v;
93
                    }
94 1
                    throw new InvalidConfigurationException('You need to configure a proxy_client to get the cache_manager needed for invalidation handling.');
95 36
                })
96 36
            ->end()
97 36
            ->validate()
98 36
                ->ifTrue(
99
                    function ($v) {
100 32
                        return $v['user_context']['logout_handler']['enabled']
101 32
                            && !isset($v['proxy_client']);
102 36
                    }
103
                )
104
                ->then(function ($v) {
105 10
                    if ('auto' === $v['user_context']['logout_handler']['enabled']) {
106 10
                        $v['user_context']['logout_handler']['enabled'] = false;
107
108 10
                        return $v;
109
                    }
110
                    throw new InvalidConfigurationException('You need to configure a proxy_client for the logout_handler.');
111 36
                })
112
        ;
113
114 36
        $this->addCacheableResponseSection($rootNode);
115 36
        $this->addCacheControlSection($rootNode);
116 36
        $this->addProxyClientSection($rootNode);
117 36
        $this->addCacheManagerSection($rootNode);
118 36
        $this->addTagSection($rootNode);
119 36
        $this->addInvalidationSection($rootNode);
120 36
        $this->addUserContextListenerSection($rootNode);
121 36
        $this->addFlashMessageSection($rootNode);
122 36
        $this->addTestSection($rootNode);
123 36
        $this->addDebugSection($rootNode);
124
125 36
        return $treeBuilder;
126
    }
127
128 36
    private function addCacheableResponseSection(ArrayNodeDefinition $rootNode)
129
    {
130
        $rootNode
131 36
            ->children()
132 36
                ->arrayNode('cacheable')
133 36
                    ->addDefaultsIfNotSet()
134 36
                    ->children()
135 36
                        ->arrayNode('response')
136 36
                            ->addDefaultsIfNotSet()
137 36
                            ->children()
138 36
                                ->arrayNode('additional_status')
139 36
                                    ->prototype('scalar')->end()
140 36
                                    ->info('Additional response HTTP status codes that will be considered cacheable.')
141 36
                                ->end()
142 36
                                ->scalarNode('expression')
143 36
                                    ->defaultNull()
144 36
                                    ->info('Expression to decide whether response is cacheable.')
145 36
                            ->end()
146 36
                        ->end()
147
148 36
                        ->validate()
149
                            ->ifTrue(function ($v) {
150 3
                                return !empty($v['additional_status']) && !empty($v['expression']);
151 36
                            })
152 36
                            ->thenInvalid('You may not set both additional_status and expression.')
153 36
                        ->end()
154 36
                    ->end()
155 36
                ->end()
156 36
            ->end();
157 36
    }
158
159
    /**
160
     * Cache header control main section.
161
     *
162
     * @param ArrayNodeDefinition $rootNode
163
     */
164 36
    private function addCacheControlSection(ArrayNodeDefinition $rootNode)
165
    {
166
        $rules = $rootNode
167 36
            ->children()
168 36
                ->arrayNode('cache_control')
169 36
                    ->fixXmlConfig('rule')
170 36
                    ->children()
171 36
                        ->arrayNode('defaults')
172 36
                            ->addDefaultsIfNotSet()
173 36
                            ->children()
174 36
                                ->booleanNode('overwrite')
175 36
                                    ->info('Whether to overwrite existing cache headers')
176 36
                                    ->defaultFalse()
177 36
                                ->end()
178 36
                            ->end()
179 36
                        ->end()
180 36
                        ->arrayNode('rules')
181 36
                            ->prototype('array')
182 36
                                ->children();
183
184 36
        $this->addMatch($rules);
185
        $rules
186 36
            ->arrayNode('headers')
187 36
                ->isRequired()
188
                // todo validate there is some header defined
189 36
                ->children()
190 36
                    ->enumNode('overwrite')
191 36
                        ->info('Whether to overwrite cache headers for this rule, defaults to the cache_control.defaults.overwrite setting')
192 36
                        ->values(['default', true, false])
193 36
                        ->defaultValue('default')
194 36
                    ->end()
195 36
                    ->arrayNode('cache_control')
196 36
                        ->info('Add the specified cache control directives.')
197 36
                        ->children()
198 36
                            ->scalarNode('max_age')->end()
199 36
                            ->scalarNode('s_maxage')->end()
200 36
                            ->booleanNode('private')->end()
201 36
                            ->booleanNode('public')->end()
202 36
                            ->booleanNode('must_revalidate')->end()
203 36
                            ->booleanNode('proxy_revalidate')->end()
204 36
                            ->booleanNode('no_transform')->end()
205 36
                            ->booleanNode('no_cache')->end()
206 36
                            ->booleanNode('no_store')->end()
207 36
                            ->scalarNode('stale_if_error')->end()
208 36
                            ->scalarNode('stale_while_revalidate')->end()
209 36
                        ->end()
210 36
                    ->end()
211 36
                    ->booleanNode('etag')
212 36
                        ->defaultValue(false)
213 36
                        ->info('Set a simple ETag which is just the md5 hash of the response body')
214 36
                    ->end()
215 36
                    ->scalarNode('last_modified')
216 36
                        ->validate()
217
                            ->ifTrue(function ($v) {
218 2
                                if (is_string($v)) {
219 2
                                    new \DateTime($v);
220
                                }
221
222 1
                                return false;
223 36
                            })
224 36
                            ->thenInvalid('') // this will never happen as new DateTime will throw an exception if $v is no date
225 36
                        ->end()
226 36
                        ->info('Set a default last modified timestamp if none is set yet. Value must be parseable by DateTime')
227 36
                    ->end()
228 36
                    ->scalarNode('reverse_proxy_ttl')
229 36
                        ->defaultNull()
230 36
                        ->info('Specify an X-Reverse-Proxy-TTL header with a time in seconds for a caching proxy under your control.')
231 36
                    ->end()
232 36
                    ->arrayNode('vary')
233
                        ->beforeNormalization()->ifString()->then(function ($v) {
234 2
                            return preg_split('/\s*,\s*/', $v);
235 36
                        })->end()
236 36
                        ->prototype('scalar')->end()
237 36
                        ->info('Define a list of additional headers on which the response varies.')
238 36
                    ->end()
239 36
                ->end()
240 36
            ->end()
241
        ;
242 36
    }
243
244
    /**
245
     * Shared configuration between cache control, tags and invalidation.
246
     *
247
     * @param NodeBuilder $rules
248
     */
249 36
    private function addMatch(NodeBuilder $rules)
250
    {
251
        $rules
252 36
            ->arrayNode('match')
253 36
                ->cannotBeOverwritten()
254 36
                ->isRequired()
255 36
                ->fixXmlConfig('method')
256 36
                ->fixXmlConfig('ip')
257 36
                ->fixXmlConfig('attribute')
258 36
                ->validate()
259
                    ->ifTrue(function ($v) {
260 8
                        return !empty($v['match_response']) && !class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage');
261 36
                    })
262 36
                    ->thenInvalid('Configured a match_response but ExpressionLanguage is not available')
263 36
                ->end()
264 36
                ->children()
265 36
                    ->scalarNode('path')
266 36
                        ->defaultNull()
267 36
                        ->info('Request path.')
268 36
                    ->end()
269 36
                    ->scalarNode('host')
270 36
                        ->defaultNull()
271 36
                        ->info('Request host name.')
272 36
                    ->end()
273 36
                    ->arrayNode('methods')
274
                        ->beforeNormalization()->ifString()->then(function ($v) {
275 3
                            return preg_split('/\s*,\s*/', $v);
276 36
                        })->end()
277 36
                        ->useAttributeAsKey('name')
278 36
                        ->prototype('scalar')->end()
279 36
                        ->info('Request HTTP methods.')
280 36
                    ->end()
281 36
                    ->arrayNode('ips')
282
                        ->beforeNormalization()->ifString()->then(function ($v) {
283 3
                            return preg_split('/\s*,\s*/', $v);
284 36
                        })->end()
285 36
                        ->useAttributeAsKey('name')
286 36
                        ->prototype('scalar')->end()
287 36
                        ->info('List of client IPs.')
288 36
                    ->end()
289 36
                    ->arrayNode('attributes')
290 36
                        ->useAttributeAsKey('name')
291 36
                        ->prototype('scalar')->end()
292 36
                        ->info('Regular expressions on request attributes.')
293 36
                    ->end()
294 36
                ->end()
295 36
            ->end()
296
        ;
297 36
    }
298
299 36
    private function addProxyClientSection(ArrayNodeDefinition $rootNode)
300
    {
301
        $rootNode
302 36
            ->children()
303 36
                ->arrayNode('proxy_client')
304 36
                    ->children()
305 36
                        ->enumNode('default')
306 36
                            ->values(['varnish', 'nginx', 'symfony', 'noop'])
307 36
                            ->info('If you configure more than one proxy client, you need to specify which client is the default.')
308 36
                        ->end()
309 36
                        ->arrayNode('varnish')
310 36
                            ->children()
311 36
                                    ->append($this->getHttpDispatcherNode())
312 36
                            ->end()
313 36
                        ->end()
314
315 36
                        ->arrayNode('nginx')
316 36
                            ->children()
317 36
                                ->scalarNode('purge_location')
318 36
                                    ->defaultValue(false)
319 36
                                    ->info('Path to trigger the purge on Nginx for different location purge.')
320 36
                                ->end()
321 36
                                ->append($this->getHttpDispatcherNode())
322 36
                            ->end()
323 36
                        ->end()
324
325 36
                        ->arrayNode('symfony')
326 36
                            ->children()
327 36
                                ->append($this->getHttpDispatcherNode())
328 36
                            ->end()
329 36
                        ->end()
330
331 36
                        ->booleanNode('noop')->end()
332
333 36
                    ->end()
334 36
                ->end()
335 36
            ->end();
336 36
    }
337
338
    /**
339
     * Get the configuration node for a HTTP dispatcher in a proxy client.
340
     *
341
     * @return NodeDefinition
342
     */
343 36
    private function getHttpDispatcherNode()
344
    {
345 36
        $treeBuilder = new TreeBuilder();
346 36
        $node = $treeBuilder->root('http');
347
348
        $node
349 36
            ->fixXmlConfig('server')
350 36
            ->isRequired()
351 36
            ->children()
352 36
                ->arrayNode('servers')
353 36
                    ->info('Addresses of the hosts the caching proxy is running on. May be hostname or ip, and with :port if not the default port 80.')
354 36
                    ->useAttributeAsKey('name')
355 36
                    ->isRequired()
356 36
                    ->requiresAtLeastOneElement()
357 36
                    ->prototype('scalar')->end()
358 36
                ->end()
359 36
                ->scalarNode('base_url')
360 36
                    ->defaultNull()
361 36
                    ->info('Default host name and optional path for path based invalidation.')
362 36
                ->end()
363 36
                ->scalarNode('http_client')
364 36
                    ->defaultNull()
365 36
                    ->info('Httplug async client service name to use for sending the requests.')
366 36
                ->end()
367 36
            ->end()
368
        ;
369
370 36
        return $node;
371
    }
372
373 36
    private function addTestSection(ArrayNodeDefinition $rootNode)
374
    {
375
        $rootNode
376 36
            ->children()
377 36
                ->arrayNode('test')
378 36
                    ->children()
379 36
                        ->scalarNode('cache_header')
380 36
                            ->defaultValue('X-Cache')
381 36
                            ->info('HTTP cache hit/miss header')
382 36
                        ->end()
383 36
                        ->arrayNode('proxy_server')
384 36
                            ->info('Configure how caching proxy will be run in your tests')
385 36
                            ->children()
386 36
                                ->enumNode('default')
387 36
                                    ->values(['varnish', 'nginx'])
388 36
                                    ->info('If you configure more than one proxy server, specify which client is the default.')
389 36
                                ->end()
390 36
                                ->arrayNode('varnish')
391 36
                                    ->children()
392 36
                                        ->scalarNode('config_file')->isRequired()->end()
393 36
                                        ->scalarNode('binary')->defaultValue('varnishd')->end()
394 36
                                        ->integerNode('port')->defaultValue(6181)->end()
395 36
                                        ->scalarNode('ip')->defaultValue('127.0.0.1')->end()
396 36
                                    ->end()
397 36
                                ->end()
398 36
                                ->arrayNode('nginx')
399 36
                                    ->children()
400 36
                                        ->scalarNode('config_file')->isRequired()->end()
401 36
                                        ->scalarNode('binary')->defaultValue('nginx')->end()
402 36
                                        ->integerNode('port')->defaultValue(8080)->end()
403 36
                                        ->scalarNode('ip')->defaultValue('127.0.0.1')->end()
404 36
                                    ->end()
405 36
                                ->end()
406 36
                            ->end()
407 36
                        ->end()
408 36
                    ->end()
409 36
                ->end()
410 36
            ->end();
411 36
    }
412
413
    /**
414
     * Cache manager main section.
415
     *
416
     * @param ArrayNodeDefinition $rootNode
417
     */
418 36
    private function addCacheManagerSection(ArrayNodeDefinition $rootNode)
419
    {
420
        $rootNode
421 36
            ->children()
422 36
                ->arrayNode('cache_manager')
423 36
                    ->addDefaultsIfNotSet()
424 36
                    ->beforeNormalization()
425 36
                        ->ifArray()
426
                        ->then(function ($v) {
427 6
                            $v['enabled'] = isset($v['enabled']) ? $v['enabled'] : true;
428
429 6
                            return $v;
430 36
                        })
431 36
                    ->end()
432 36
                    ->info('Configure the cache manager. Needs a proxy_client to be configured.')
433 36
                    ->children()
434 36
                        ->enumNode('enabled')
435 36
                            ->values([true, false, 'auto'])
436 36
                            ->defaultValue('auto')
437 36
                            ->info('Allows to disable the invalidation manager. Enabled by default if you configure a proxy client.')
438 36
                        ->end()
439 36
                        ->scalarNode('custom_proxy_client')
440 36
                            ->info('Service name of a custom proxy client to use. With a custom client, generate_url_type defaults to ABSOLUTE_URL and tag support needs to be explicitly enabled. If no custom proxy client is specified, the first proxy client you configured is used.')
441 36
                            ->cannotBeEmpty()
442 36
                        ->end()
443 36
                        ->enumNode('generate_url_type')
444 36
                            ->values([
445 36
                                'auto',
446
                                UrlGeneratorInterface::ABSOLUTE_PATH,
447
                                UrlGeneratorInterface::ABSOLUTE_URL,
448
                                UrlGeneratorInterface::NETWORK_PATH,
449
                                UrlGeneratorInterface::RELATIVE_PATH,
450
                            ])
451 36
                            ->defaultValue('auto')
452 36
                            ->info('Set what URLs to generate on invalidate/refresh Route. Auto means path if base_url is set on the default proxy client, full URL otherwise.')
453 36
                        ->end()
454 36
                    ->end()
455
        ;
456 36
    }
457
458 36
    private function addTagSection(ArrayNodeDefinition $rootNode)
459
    {
460
        $rules = $rootNode
461 36
            ->children()
462 36
                ->arrayNode('tags')
463 36
                    ->addDefaultsIfNotSet()
464 36
                    ->fixXmlConfig('rule')
465 36
                    ->children()
466 36
                        ->enumNode('enabled')
467 36
                            ->values([true, false, 'auto'])
468 36
                            ->defaultValue('auto')
469 36
                            ->info('Allows to disable the event subscriber for tag configuration and annotations when your project does not use the annotations. Enabled by default if you configured the cache manager.')
470 36
                        ->end()
471 36
                        ->booleanNode('strict')->defaultFalse()->end()
472 36
                        ->scalarNode('expression_language')
473 36
                            ->defaultNull()
474 36
                            ->info('Service name of a custom ExpressionLanugage to use.')
475 36
                        ->end()
476 36
                        ->scalarNode('header')
477 36
                            ->defaultValue('X-Cache-Tags')
478 36
                            ->info('HTTP header that contains cache tags')
479 36
                        ->end()
480 36
                        ->arrayNode('rules')
481 36
                            ->prototype('array')
482 36
                                ->fixXmlConfig('tag')
483 36
                                ->fixXmlConfig('tag_expression')
484 36
                                ->validate()
485 36
                                    ->ifTrue(function ($v) {
486 3
                                        return !empty($v['tag_expressions']) && !class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage');
487 36
                                    })
488 36
                                    ->thenInvalid('Configured a tag_expression but ExpressionLanugage is not available')
489 36
                                ->end()
490 36
                                ->children();
491
492 36
        $this->addMatch($rules);
493
494
        $rules
495 36
            ->arrayNode('tags')
496 36
                ->prototype('scalar')
497 36
                ->info('Tags to add to the response on safe requests, to invalidate on unsafe requests')
498 36
            ->end()->end()
499 36
            ->arrayNode('tag_expressions')
500 36
                ->prototype('scalar')
501 36
                ->info('Tags to add to the response on safe requests, to invalidate on unsafe requests')
502 36
            ->end()
503
        ;
504 36
    }
505
506 36
    private function addInvalidationSection(ArrayNodeDefinition $rootNode)
507
    {
508
        $rules = $rootNode
509 36
            ->children()
510 36
                ->arrayNode('invalidation')
511 36
                    ->fixXmlConfig('rule')
512 36
                    ->addDefaultsIfNotSet()
513 36
                    ->children()
514 36
                        ->enumNode('enabled')
515 36
                            ->values([true, false, 'auto'])
516 36
                            ->defaultValue('auto')
517 36
                            ->info('Allows to disable the listener for invalidation. Enabled by default if the cache manager is configured. When disabled, the cache manager is no longer flushed automatically.')
518 36
                        ->end()
519 36
                        ->scalarNode('expression_language')
520 36
                            ->defaultNull()
521 36
                            ->info('Service name of a custom ExpressionLanugage to use.')
522 36
                        ->end()
523 36
                        ->arrayNode('rules')
524 36
                            ->info('Set what requests should invalidate which target routes.')
525 36
                            ->prototype('array')
526 36
                                ->fixXmlConfig('route')
527 36
                                ->children();
528
529 36
        $this->addMatch($rules);
530
        $rules
531 36
            ->arrayNode('routes')
532 36
                ->isRequired()
533 36
                ->requiresAtLeastOneElement()
534 36
                ->useAttributeAsKey('name')
535 36
                ->info('Target routes to invalidate when request is matched')
536 36
                ->prototype('array')
537 36
                    ->children()
538 36
                        ->booleanNode('ignore_extra_params')->defaultTrue()->end()
539 36
                    ->end()
540 36
                ->end()
541 36
            ->end();
542 36
    }
543
544
    /**
545
     * User context main section.
546
     *
547
     * @param ArrayNodeDefinition $rootNode
548
     */
549 36
    private function addUserContextListenerSection(ArrayNodeDefinition $rootNode)
550
    {
551
        $rootNode
552 36
            ->children()
553 36
                ->arrayNode('user_context')
554 36
                    ->info('Listener that returns the request for the user context hash as early as possible.')
555 36
                    ->addDefaultsIfNotSet()
556 36
                    ->canBeEnabled()
557 36
                    ->fixXmlConfig('user_identifier_header')
558 36
                    ->children()
559 36
                        ->arrayNode('match')
560 36
                            ->addDefaultsIfNotSet()
561 36
                            ->children()
562 36
                                ->scalarNode('matcher_service')
563 36
                                    ->defaultValue('fos_http_cache.user_context.request_matcher')
564 36
                                    ->info('Service id of a request matcher that tells whether the request is a context hash request.')
565 36
                                ->end()
566 36
                                ->scalarNode('accept')
567 36
                                    ->defaultValue('application/vnd.fos.user-context-hash')
568 36
                                    ->info('Specify the accept HTTP header used for context hash requests.')
569 36
                                ->end()
570 36
                                ->scalarNode('method')
571 36
                                    ->defaultNull()
572 36
                                    ->info('Specify the HTTP method used for context hash requests.')
573 36
                                ->end()
574 36
                            ->end()
575 36
                        ->end()
576 36
                        ->scalarNode('hash_cache_ttl')
577 36
                            ->defaultValue(0)
578 36
                            ->info('Cache the response for the hash for the specified number of seconds. Setting this to 0 will not cache those responses at all.')
579 36
                        ->end()
580 36
                        ->booleanNode('always_vary_on_context_hash')
581 36
                            ->defaultTrue()
582 36
                            ->info('Whether to always add the user context hash header name in the response Vary header.')
583 36
                        ->end()
584 36
                        ->arrayNode('user_identifier_headers')
585 36
                            ->prototype('scalar')->end()
586 36
                            ->defaultValue(['Cookie', 'Authorization'])
587 36
                            ->info('List of headers that contains the unique identifier for the user in the hash request.')
588 36
                        ->end()
589 36
                        ->scalarNode('user_hash_header')
590 36
                            ->defaultValue('X-User-Context-Hash')
591 36
                            ->info('Name of the header that contains the hash information for the context.')
592 36
                        ->end()
593 36
                        ->booleanNode('role_provider')
594 36
                            ->defaultFalse()
595 36
                            ->info('Whether to enable a provider that automatically adds all roles of the current user to the context.')
596 36
                        ->end()
597 36
                        ->arrayNode('logout_handler')
598 36
                            ->addDefaultsIfNotSet()
599 36
                            ->canBeEnabled()
600 36
                            ->children()
601 36
                                ->enumNode('enabled')
602 36
                                    ->values([true, false, 'auto'])
603 36
                                    ->defaultValue('auto')
604 36
                                    ->info('Whether to enable the user context logout handler.')
605 36
                                ->end()
606 36
                            ->end()
607 36
                        ->end()
608 36
                    ->end()
609 36
                ->end()
610 36
            ->end()
611
        ;
612 36
    }
613
614 36
    private function addFlashMessageSection(ArrayNodeDefinition $rootNode)
615
    {
616
        $rootNode
617 36
            ->children()
618 36
                ->arrayNode('flash_message')
619 36
                    ->canBeUnset()
620 36
                    ->canBeEnabled()
621 36
                    ->info('Activate the flash message listener that puts flash messages into a cookie.')
622 36
                    ->children()
623 36
                        ->scalarNode('name')
624 36
                            ->defaultValue('flashes')
625 36
                            ->info('Name of the cookie to set for flashes.')
626 36
                        ->end()
627 36
                        ->scalarNode('path')
628 36
                            ->defaultValue('/')
629 36
                            ->info('Cookie path validity.')
630 36
                        ->end()
631 36
                        ->scalarNode('host')
632 36
                            ->defaultNull()
633 36
                            ->info('Cookie host name validity.')
634 36
                        ->end()
635 36
                        ->scalarNode('secure')
636 36
                            ->defaultFalse()
637 36
                            ->info('Whether the cookie should only be transmitted over a secure HTTPS connection from the client.')
638 36
                        ->end()
639 36
                    ->end()
640 36
                ->end()
641 36
            ->end();
642 36
    }
643
644 36
    private function addDebugSection(ArrayNodeDefinition $rootNode)
645
    {
646
        $rootNode
647 36
            ->children()
648 36
                ->arrayNode('debug')
649 36
                ->addDefaultsIfNotSet()
650 36
                ->canBeEnabled()
651 36
                ->children()
652 36
                    ->booleanNode('enabled')
653 36
                        ->defaultValue($this->debug)
654 36
                        ->info('Whether to send a debug header with the response to trigger a caching proxy to send debug information. If not set, defaults to kernel.debug.')
655 36
                    ->end()
656 36
                    ->scalarNode('header')
657 36
                        ->defaultValue('X-Cache-Debug')
658 36
                        ->info('The header to send if debug is true.')
659 36
                    ->end()
660 36
                ->end()
661 36
            ->end()
662 36
        ->end();
663 36
    }
664
}
665