Completed
Push — master ( ff4180...f6540e )
by Yohan
07:27
created

EventProviderPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
cbo 3
dl 0
loc 14
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 9 4
1
<?php
2
3
/*
4
 * This file is part of CalendR, a Fréquence web project.
5
 *
6
 * (c) 2012 Fréquence web
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 CalendR\Bridge\Symfony\Bundle\DependencyInjection\Compiler;
13
14
use CalendR\Event\Manager;
15
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Reference;
18
19
class EventProviderPass implements CompilerPassInterface
20
{
21
    const TAG = 'calendr.event_provider';
22
23
    public function process(ContainerBuilder $container)
24
    {
25
        $eventManager = $container->getDefinition(Manager::class);
26
27
        foreach ($container->findTaggedServiceIds(self::TAG) as $id => $attributes) {
28
            $providerAlias = isset($attributes[0]) && isset($attributes[0]['alias']) ? $attributes[0]['alias'] : $id;
29
            $eventManager->addMethodCall('addProvider', [$providerAlias, new Reference($id)]);
30
        }
31
    }
32
}
33