AddPagerfantasPass   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 15 4
1
<?php
2
3
/*
4
 * This file is part of the Pagerfanta package.
5
 *
6
 * (c) Pablo Díez <[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 WhiteOctober\PagerfantaBundle\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
 * AddPagerfantasPass.
20
 *
21
 * @author Pablo Díez <[email protected]>
22
 */
23
class AddPagerfantasPass implements CompilerPassInterface
24
{
25
    public function process(ContainerBuilder $container)
26
    {
27
        if (!$container->hasDefinition('white_october_pagerfanta.view_factory')) {
28
            return;
29
        }
30
31
        $views = array();
32
        foreach ($container->findTaggedServiceIds('pagerfanta.view') as $serviceId => $arguments) {
33
            $alias = isset($arguments[0]['alias']) ? $arguments[0]['alias'] : $serviceId;
34
35
            $views[$alias] = new Reference($serviceId);
36
        }
37
38
        $container->getDefinition('white_october_pagerfanta.view_factory')->addMethodCall('add', array($views));
39
    }
40
}
41