CacheTaggingPass::process()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 1
crap 3
1
<?php
2
3
/*
4
 * This file is part of php-cache\cache-bundle package.
5
 *
6
 * (c) 2015 Aaron Scherer <[email protected]>, Tobias Nyholm <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Cache\CacheBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
17
/**
18
 * Make sure to tag all cache services we can find.
19
 *
20
 * @author Tobias Nyholm <[email protected]>
21
 */
22
class CacheTaggingPass implements CompilerPassInterface
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27 1
    public function process(ContainerBuilder $container)
28
    {
29
        // get service ids form parameters
30 1
        $serviceIds = $container->getParameter('cache.provider_service_ids');
31
32 1
        foreach ($serviceIds as $id) {
33 1
            $def = $container->findDefinition($id);
34 1
            if (!$def->hasTag('cache.provider')) {
35 1
                $def->addTag('cache.provider');
36
            }
37
        }
38 1
    }
39
}
40