Completed
Push — master ( 8f1795...739459 )
by David
06:57
created

FOSHttpCacheBundle   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Test Coverage

Coverage 92.31%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 7
dl 0
loc 29
ccs 12
cts 13
cp 0.9231
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerCommands() 0 4 1
A build() 0 18 4
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;
13
14
use FOS\HttpCache\UserContext\ContextProvider;
15
use FOS\HttpCacheBundle\DependencyInjection\Compiler\HashGeneratorPass;
16
use FOS\HttpCacheBundle\DependencyInjection\Compiler\LoggerPass;
17
use FOS\HttpCacheBundle\DependencyInjection\Compiler\SessionListenerRemovePass;
18
use FOS\HttpCacheBundle\DependencyInjection\Compiler\TagListenerPass;
19
use Symfony\Component\Console\Application;
20
use Symfony\Component\DependencyInjection\ContainerBuilder;
21
use Symfony\Component\HttpKernel\Bundle\Bundle;
22
use Symfony\Component\HttpKernel\Kernel;
23
24
class FOSHttpCacheBundle extends Bundle
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29 2
    public function build(ContainerBuilder $container)
30
    {
31 2
        $container->addCompilerPass(new LoggerPass());
32 2
        $container->addCompilerPass(new TagListenerPass());
33 2
        $container->addCompilerPass(new HashGeneratorPass());
34 2
        if (version_compare(Kernel::VERSION, '3.4', '>=')
35 2
            && version_compare(Kernel::VERSION, '4.1', '<')
36
        ) {
37
            $container->addCompilerPass(new SessionListenerRemovePass());
38
        }
39
40
        // Symfony 3.3 and higher
41 2
        if (method_exists($container, 'registerForAutoconfiguration')) {
42
            $container
43 2
                ->registerForAutoconfiguration(ContextProvider::class)
44 2
                ->addTag('fos_http_cache.user_context_provider');
45
        }
46 2
    }
47
48 4
    public function registerCommands(Application $application)
49
    {
50
        // do nothing, commands are registered as services
51 4
    }
52
}
53