RegisterExtendableRendererPass::process()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 10
cts 10
cp 1
rs 9.6333
c 0
b 0
f 0
cc 4
nc 4
nop 1
crap 4
1
<?php
2
3
/*
4
 * This file is part of the Ivory Google Map bundle package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\GoogleMapBundle\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 GeLo <[email protected]>
20
 */
21
class RegisterExtendableRendererPass implements CompilerPassInterface
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26 57
    public function process(ContainerBuilder $container)
27
    {
28 57
        $tag = 'ivory.google_map.helper.renderer.extendable';
29 57
        $extendableRenderer = $container->getDefinition('ivory.google_map.helper.renderer.overlay.extendable');
30
31 57
        foreach ($container->findTaggedServiceIds($tag) as $id => $attributes) {
32 57
            foreach ($attributes as $attribute) {
33 57
                if (!isset($attribute['class'])) {
34 1
                    throw new \RuntimeException(sprintf(
35 1
                        'No "class" attribute found for the tag "%s" on the service "%s".',
36
                        $tag,
37
                        $id
38
                    ));
39
                }
40
41 56
                $extendableRenderer->addMethodCall('setRenderer', [$attribute['class'], new Reference($id)]);
42
            }
43
        }
44 56
    }
45
}
46