ProviderPass   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
cbo 3
dl 0
loc 26
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 20 5
1
<?php
2
3
/*
4
 * This file is part of the XabbuhPandaBundle package.
5
 *
6
 * (c) Christian Flothmann <[email protected]>
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 Xabbuh\PandaBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16
use Symfony\Component\DependencyInjection\Reference;
17
18
/**
19
 * Implementation of a compiler pass which registers tagged services as
20
 * providers for clouds and accounts on the corresponding managers.
21
 *
22
 * @author Christian Flothmann <[email protected]>
23
 */
24
class ProviderPass implements CompilerPassInterface
25
{
26
    /**
27
     * {@inheritDoc}
28
     */
29 8
    public function process(ContainerBuilder $container)
30
    {
31
        // add account providers
32 8
        if ($container->has("xabbuh_panda.account_manager")) {
33 7
            $accountManager = $container->findDefinition("xabbuh_panda.account_manager");
34 7
            $accountProviderServices = $container->findTaggedServiceIds("xabbuh_panda.account_provider");
35 7
            foreach ($accountProviderServices as $id => $tags) {
36 3
                $accountManager->addMethodCall("registerProvider", array(new Reference($id)));
37
            }
38
        }
39
40
        // add cloud providers
41 8
        if ($container->has("xabbuh_panda.cloud_manager")) {
42 7
            $cloudManager = $container->findDefinition("xabbuh_panda.cloud_manager");
43 7
            $cloudProviderServices = $container->findTaggedServiceIds("xabbuh_panda.cloud_provider");
44 7
            foreach ($cloudProviderServices as $id => $tags) {
45 3
                $cloudManager->addMethodCall("registerProvider", array(new Reference($id)));
46
            }
47
        }
48 8
    }
49
}
50