MailhookCompilerPass::process()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 3
nc 3
nop 1
1
<?php
2
3
namespace Swm\Bundle\MailHookBundle\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 MailhookCompilerPass implements CompilerPassInterface
10
{
11
    public function process(ContainerBuilder $container)
12
    {
13
        foreach ($container->findTaggedServiceIds('swm.mailhook') as $id => $tag) {
14
            $tag = array_pop($tag);
15
16
            if (!isset($tag['alias'])) {
17
                throw new \Exception('You should define an alias for all "swm.mailhook" tagged services');
18
            }
19
20
            $container->getDefinition('swm.mail_hook.provider.api_service')
21
                ->addMethodCall('setApiService', array($tag['alias'], $container->getDefinition($id)));
22
        }
23
    }
24
}