Completed
Push — master ( 8be640...eaa368 )
by Aaron
22:16
created

ServiceAliasCompilerPass::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file is part of cache-bundle.
5
 *
6
 * (c) Aaron Scherer <[email protected]>
7
 *
8
 * This source file is subject to the license that is bundled
9
 * with this source code in the file LICENSE
10
 */
11
12
namespace Cache\AdapterBundle\DependencyInjection\CompilerPass;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
17
/**
18
 * @author Aaron Scherer <[email protected]>
19
 *
20
 * ServiceAliasCompilerPass Class
21
 */
22
class ServiceAliasCompilerPass implements CompilerPassInterface
23
{
24
25
    /**
26
     * You can modify the container here before it is dumped to PHP code.
27
     *
28
     * @param ContainerBuilder $container
29
     */
30
    public function process(ContainerBuilder $container)
31
    {
32
        $serviceIds = array_keys($container->findTaggedServiceIds('cache.provider'));
33
        foreach ($serviceIds as $serviceId) {
34
            $cleanName = str_replace('.inner', '', $serviceId);
35
            $instance  = $container->get($serviceId);
36
            $class     = get_class($instance);
37
38
            $container->setAlias($cleanName, $serviceId);
39
            $container->setAlias($class, $cleanName);
40
        }
41
    }
42
}
43