Completed
Push — 0.3.x ( 921e84...1e8c09 )
by Dmitry
14:16
created

ServiceProvidersPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 9
c 1
b 0
f 1
nc 3
nop 1
dl 0
loc 17
ccs 12
cts 12
cp 1
crap 3
rs 9.4285
1
<?php
2
3
namespace Krtv\Bundle\SingleSignOnIdentityProviderBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
8
/**
9
 * Class ServiceProvidersPass
10
 * @package Krtv\Bundle\SingleSignOnIdentityProviderBundle\DependencyInjection\Compiler
11
 */
12
class ServiceProvidersPass implements CompilerPassInterface
13
{
14
    /**
15
     * {@inheritDoc}
16
     */
17 1
    public function process(ContainerBuilder $container)
18
    {
19 1
        $services = array();
20
21 1
        $activeServices = $container->getParameter('krtv_single_sign_on_identity_provider.services');
22
23 1
        foreach ($container->findTaggedServiceIds('sso.service_provider') as $id => $attributes) {
24 1
            $name = $attributes[0]['service'];
25
26 1
            if (in_array($name, $activeServices)) {
27 1
                $services[$name] = $container->getDefinition($id);
28 1
            }
29 1
        }
30
31 1
        $container->getDefinition('krtv_single_sign_on_identity_provider.manager.service_manager')
32 1
            ->replaceArgument(3, $services);
33 1
    }
34
}
35