Completed
Push — master ( e97541...8b5dee )
by Karel
12s
created

RequestCompilerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 21
ccs 8
cts 10
cp 0.8
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 15 3
1
<?php
2
3
/**
4
 * This file is part of the FOSElasticaBundle project.
5
 *
6
 * (c) Tim Nagel <[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 FOS\ElasticaBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\ContainerInterface;
17
use Symfony\Component\DependencyInjection\Reference;
18
19
final class RequestCompilerPass implements CompilerPassInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24 12
    public function process(ContainerBuilder $container)
25
    {
26 12
        if (!$container->hasDefinition('fos_elastica.paginator.subscriber')) {
27
            return;
28
        }
29
30 12
        $definition = $container->getDefinition('fos_elastica.paginator.subscriber');
31 12
        if ($container->hasDefinition('request_stack')) {
32 12
            $arguments = array(new Reference('request_stack', ContainerInterface::NULL_ON_INVALID_REFERENCE, false));
33 12
        } else {
34
            $arguments = array(new Reference('request', ContainerInterface::NULL_ON_INVALID_REFERENCE, false));
35
        }
36
37 12
        $definition->addMethodCall('setRequest', $arguments);
38 12
    }
39
}
40