Extension::load()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
namespace Dkplus\CsrfApiUnprotectionBundle\DependencyInjection;
3
4
use Symfony\Component\DependencyInjection\ContainerBuilder;
5
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
6
use Symfony\Component\Config\FileLocator;
7
use Symfony\Component\HttpKernel\DependencyInjection\Extension as BaseExtension;
8
9
class Extension extends BaseExtension
10
{
11 5
    public function getAlias()
12
    {
13 5
        return 'dkplus_csrf_api_unprotection';
14
    }
15
16 4
    public function getConfiguration(array $config, ContainerBuilder $container)
17
    {
18 4
        return new Configuration($this->getAlias());
19
    }
20
21
    /**
22
     * Loads a specific configuration.
23
     *
24
     * @param array $config An array of configuration values
25
     * @param ContainerBuilder $container A ContainerBuilder instance
26
     *
27
     * @throws \InvalidArgumentException When provided tag is not defined in this extension
28
     *
29
     * @api
30
     */
31 3
    public function load(array $config, ContainerBuilder $container)
32
    {
33 3
        $config = $this->processConfiguration($this->getConfiguration($config, $container), $config);
34
35 3
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
36 3
        $loader->load('services.xml');
37
38 3
        $uriPatterns = $container->getDefinition('dkplus_csrf_api_unprotection.unprotection_rule.uri_patterns');
39 3
        $uriPatterns->setArguments([$config['rules']['match_uri']]);
40 3
    }
41
}
42