Completed
Push — master ( da2f6e...d3b8cb )
by Kamil
20:06
created

SitemapProviderPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 13 3
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
 
12
namespace Sylius\Bundle\CoreBundle\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 Arkadiusz Krakowiak <[email protected]>
20
 */
21
class SitemapProviderPass implements CompilerPassInterface
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function process(ContainerBuilder $container)
27
    {
28
        if (!$container->has('sylius.sitemap_builder')) {
29
            return;
30
        }
31
32
        $builderDefinition = $container->findDefinition('sylius.sitemap_builder');
33
        $taggedProviders = $container->findTaggedServiceIds('sylius.sitemap_provider');
34
35
        foreach ($taggedProviders as $id => $tags) {
36
            $builderDefinition->addMethodCall('addProvider', [(new Reference($id))]);
37
        }
38
    }
39
}
40