Completed
Push — master ( 66ec7e...c9ec0a )
by Matze
07:32
created

MiddlewareCompilerPass::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2.0054

Importance

Changes 6
Bugs 0 Features 2
Metric Value
c 6
b 0
f 2
dl 0
loc 13
ccs 8
cts 9
cp 0.8889
rs 9.4285
cc 2
eloc 8
nc 2
nop 1
crap 2.0054
1
<?php
2
3
namespace BrainExe\Core\DependencyInjection\CompilerPass;
4
5
use BrainExe\Core\Annotations\CompilerPass;
6
7
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Reference;
10
11
/**
12
 * @CompilerPass
13
 */
14
class MiddlewareCompilerPass implements CompilerPassInterface
15
{
16
17
    const TAG = 'middleware';
18
19
    /**
20
     * {@inheritdoc}
21
     */
22 2
    public function process(ContainerBuilder $container)
23
    {
24 2
        $appKernel   = $container->getDefinition('AppKernel');
25 2
        $middlewares = $container->getParameter('application.middlewares');
26
27 2
        $references  = [];
28 2
        foreach ($middlewares as $serviceId) {
29
            $references[] = new Reference($serviceId);
30
        }
31
32 2
        $appKernel->replaceArgument(3, $references);
33 2
        $container->setParameter('application.middlewares', []);
34 2
    }
35
}
36