SitemapProviderPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 15
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 13 3
1
<?php
2
3
namespace JeroenDesloovere\SitemapBundle\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 SitemapProviderPass implements CompilerPassInterface
10
{
11
    public function process(ContainerBuilder $container): void
12
    {
13
        if (!$container->has('sitemap.providers')) {
14
            return;
15
        }
16
17
        $definition = $container->findDefinition('sitemap.providers');
18
        $taggedServices = $container->findTaggedServiceIds('sitemap.provider');
19
20
        foreach ($taggedServices as $id => $tags) {
21
            // add the SitemapProvider service to the SitemapProviders service
22
            $definition->addMethodCall('add', [
23
                new Reference($id),
24
            ]);
25
        }
26
    }
27
}
28