SessionListenerPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 18
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 12 3
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\Compiler;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
17
/**
18
 * Undo our workarounds for the Symfony session listener when the session
19
 * system of Symfony has not been activated.
20
 *
21
 * - Set the hasSessionListener option of the UserContextListener to false to
22
 *   avoid the AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER being
23
 *   leaked to clients.
24
 * - Remove the session listener decorator we configured.
25
 */
26
class SessionListenerPass implements CompilerPassInterface
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function process(ContainerBuilder $container)
32
    {
33
        if ($container->has('session_listener')) {
34
            return;
35
        }
36
37
        if ($container->hasDefinition('fos_http_cache.event_listener.user_context')) {
38
            $contextListener = $container->getDefinition('fos_http_cache.event_listener.user_context');
39
            $contextListener->setArgument(5, false);
40
        }
41
        $container->removeDefinition('fos_http_cache.user_context.session_listener');
42
    }
43
}
44