Completed
Pull Request — master (#1)
by Indra
02:41
created

IndragunawanMiddlewareExtension::load()   A

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
/*
4
 * This file is part of the MiddlewareBundle
5
 *
6
 * (c) Indra Gunawan <[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 Indragunawan\MiddlewareBundle\DependencyInjection;
13
14
use Indragunawan\MiddlewareBundle\Middleware\AfterFilterInterface;
15
use Indragunawan\MiddlewareBundle\Middleware\BeforeFilterInterface;
16
use Symfony\Component\Config\FileLocator;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
19
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
20
21
/**
22
 * @author Indra Gunawan <[email protected]>
23
 */
24
final class IndragunawanMiddlewareExtension extends Extension
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function load(array $configs, ContainerBuilder $container)
30
    {
31
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
32
        $loader->load('services.xml');
33
34
        $container->registerForAutoconfiguration(BeforeFilterInterface::class)
35
            ->addTag('indragunawan.middleware', ['event' => 'before_filter']);
36
37
        $container->registerForAutoconfiguration(AfterFilterInterface::class)
38
            ->addTag('indragunawan.middleware', ['event' => 'after_filter']);
39
    }
40
}
41