IndragunawanMiddlewareExtension::load()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 2
dl 0
loc 10
ccs 0
cts 8
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the MiddlewareBundle
7
 *
8
 * (c) Indra Gunawan <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Indragunawan\MiddlewareBundle\DependencyInjection;
15
16
use Indragunawan\MiddlewareBundle\Middleware\AfterFilterInterface;
17
use Indragunawan\MiddlewareBundle\Middleware\BeforeFilterInterface;
18
use Symfony\Component\Config\FileLocator;
19
use Symfony\Component\DependencyInjection\ContainerBuilder;
20
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
21
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
22
23
/**
24
 * @author Indra Gunawan <[email protected]>
25
 */
26
final class IndragunawanMiddlewareExtension extends Extension
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function load(array $configs, ContainerBuilder $container)
32
    {
33
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
34
        $loader->load('services.xml');
35
36
        $container->registerForAutoconfiguration(BeforeFilterInterface::class)
37
            ->addTag('indragunawan.middleware', ['event' => 'before_filter']);
38
39
        $container->registerForAutoconfiguration(AfterFilterInterface::class)
40
            ->addTag('indragunawan.middleware', ['event' => 'after_filter']);
41
    }
42
}
43