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

MiddlewareCompilerPass   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 88.89%

Importance

Changes 6
Bugs 0 Features 2
Metric Value
wmc 2
c 6
b 0
f 2
lcom 0
cbo 3
dl 0
loc 22
ccs 8
cts 9
cp 0.8889
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 13 2
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