Passed
Push — master ( 896e22...61bd56 )
by Dāvis
03:36
created

UrlProviderPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 3
nop 1
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Sludio\HelperBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
class UrlProviderPass implements CompilerPassInterface
10
{
11
    public function process(ContainerBuilder $container)
12
    {
13
        if (!$container->hasParameter('sludio_helper.sitemap.enabled')) {
14
            return;
15
        }
16
        $format = $container->getParameter('sludio_helper.sitemap.format');
17
        $type = $container->getParameter('sludio_helper.sitemap.type');
18
19
        $definition = $container->getDefinition("sludio_helper.sitemap.{$format}.{$type}");
20
21
        foreach ($container->findTaggedServiceIds('sludio_helper.sitemap.provider') as $id => $attributes) {
22
            $definition->addMethodCall('addProvider', [new Reference($id)]);
23
        }
24
    }
25
}