ThemeProviderCompilerPass::process()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 20
rs 9.4286
cc 3
eloc 11
nc 3
nop 1
1
<?php
2
3
namespace Neirda\Bundle\LiipThemeProvider\DependencyInjection\CompilerPass;
4
5
use Neirda\Bundle\LiipThemeProvider\LiipThemeProviderTags;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
class ThemeProviderCompilerPass implements CompilerPassInterface
11
{
12
    /**
13
     * Register all the theme provider in the theme container.
14
     *
15
     * {@inheritdoc}
16
     */
17
    public function process(ContainerBuilder $container)
18
    {
19
        if (!$container->has('liip_theme_provider.theme_container')) {
20
            return;
21
        }
22
23
        $definition = $container->findDefinition(
24
            'liip_theme_provider.theme_container'
25
        );
26
27
        $taggedServices = $container->findTaggedServiceIds(
28
            LiipThemeProviderTags::THEME_PROVIDER
29
        );
30
        foreach ($taggedServices as $id => $tags) {
31
            $definition->addMethodCall(
32
                'addThemeProvider',
33
                array(new Reference($id))
34
            );
35
        }
36
    }
37
}
38