Completed
Push — master ( 4e719a...6b75eb )
by David
04:31
created

SessionListenerRemovePass::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.2559

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 3
cts 5
cp 0.6
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 2.2559
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
 * Remove the session listener decorator again if the application has no session listener.
19
 *
20
 * This will happen on some APIs when the session system is not activated.
21
 */
22
class SessionListenerRemovePass implements CompilerPassInterface
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27 2
    public function process(ContainerBuilder $container)
28
    {
29 2
        if ($container->has('session_listener')) {
30 2
            return;
31
        }
32
33
        $container->removeDefinition('fos_http_cache.user_context.session_listener');
34
    }
35
}
36