Completed
Pull Request — master (#299)
by David
67:30 queued 64:42
created

LoggerPass::process()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 2
nop 1
crap 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
 * Attach Symfony2 logger to cache manager.
19
 */
20
class LoggerPass implements CompilerPassInterface
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25 3
    public function process(ContainerBuilder $container)
26
    {
27 3
        if (!$container->has('logger') || !$container->has('fos_http_cache.event_listener.log')) {
28 1
            return;
29
        }
30
31 2
        $subscriber = $container->getDefinition('fos_http_cache.event_listener.log')
32 2
            ->setAbstract(false);
33
34 2
        $container->getDefinition('fos_http_cache.cache_manager')
35 2
            ->addMethodCall('addSubscriber', array($subscriber));
36 2
    }
37
}
38