Completed
Push — 2.x-dev-kit ( 3d52ae )
by
unknown
09:33
created

CacheCompilerPass   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
c 2
b 0
f 0
lcom 0
cbo 0
dl 0
loc 33
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 27 6
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
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 Sonata\CacheBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Reference;
17
18
/**
19
 * @author Thomas Rabaix <[email protected]>
20
 */
21
class CacheCompilerPass implements CompilerPassInterface
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function process(ContainerBuilder $container)
27
    {
28
        $caches = array();
29
30
        foreach ($container->findTaggedServiceIds('sonata.cache') as $id => $attributes) {
31
            if (!$container->hasDefinition($id)) {
32
                continue;
33
            }
34
35
            $caches[$id] = new Reference($id);
36
        }
37
38
        if ($container->hasDefinition('sonata.cache.orm.event_subscriber.default')) {
39
            $container->getDefinition('sonata.cache.orm.event_subscriber.default')
40
                ->replaceArgument(1, $caches);
41
        }
42
43
        if ($container->hasDefinition('sonata.cache.phpcr_odm.event_subscriber.default')) {
44
            $container->getDefinition('sonata.cache.phpcr_odm.event_subscriber.default')
45
                ->replaceArgument(1, $caches);
46
        }
47
48
        if ($container->hasDefinition('sonata.cache.manager')) {
49
            $container->getDefinition('sonata.cache.manager')
50
                ->replaceArgument(1, $caches);
51
        }
52
    }
53
}
54