Completed
Push — master ( b05893...eedd1b )
by Julito
09:17
created

ToolCompilerClass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 1
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CoreBundle\DependencyInjection\Compiler;
5
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
/**
11
 * Class ToolCompilerClass.
12
 * Search the services with tag "chamilo_core.tool" in order to be added
13
 * as a tool (Documents, Notebook, etc).
14
 */
15
class ToolCompilerClass implements CompilerPassInterface
16
{
17
    /**
18
     * @param ContainerBuilder $container
19
     */
20
    public function process(ContainerBuilder $container)
21
    {
22
        if (!$container->hasDefinition('chamilo_core.tool_chain')) {
23
            return;
24
        }
25
26
        $definition = $container->getDefinition('chamilo_core.tool_chain');
27
        $taggedServices = $container->findTaggedServiceIds('chamilo_core.tool');
28
        foreach ($taggedServices as $id => $attributes) {
29
            $definition->addMethodCall('addTool', [new Reference($id)]);
30
        }
31
    }
32
}
33