AuthenticationAttributesProviderPass::process()   B
last analyzed

Complexity

Conditions 5
Paths 4

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 10
nc 4
nop 1
1
<?php
2
3
namespace Kuleuven\AuthenticationBundle\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
class AuthenticationAttributesProviderPass implements CompilerPassInterface
10
{
11
    public function process(ContainerBuilder $container)
12
    {
13
        if (!$container->has('kuleuven_authentication.service.shibboleth_attributes_injector_manager')) {
14
            return;
15
        }
16
17
        $definition = $container->findDefinition('kuleuven_authentication.service.shibboleth_attributes_injector_manager');
18
19
        $taggedServices = $container->findTaggedServiceIds('kuleuven_authentication.shibboleth_attributes_injector');
20
21
        foreach ($taggedServices as $id => $tags) {
22
            foreach ($tags as $attributes) {
23
                $definition->addMethodCall('addProvider', [
24
                    new Reference($id),
25
                    isset($attributes['priority']) ? $attributes['priority'] : 0,
26
                ]);
27
            }
28
        }
29
    }
30
}
31