Passed
Push — develop ( 72b794...32ce71 )
by Mathieu
02:24
created

SonataAnnotationExtension   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 13
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 19 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Neimheadh\SonataAnnotationBundle\DependencyInjection;
6
7
use Symfony\Component\Config\FileLocator;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
10
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
11
12
/**
13
 * @author Marko Kunic <[email protected]>
14
 * @author Mathieu Wambre <[email protected]>
15
 */
16
final class SonataAnnotationExtension extends Extension
17
{
18
19
    public function load(array $configs, ContainerBuilder $container): void
20
    {
21
        $configuration = new Configuration();
22
        $config = $this->processConfiguration($configuration, $configs);
23
24
        $container->setParameter(
25
            'sonata_annotation.directory',
26
            $config['directory'] ?? $container->getParameter(
27
                'kernel.project_dir'
28
            ) . '/src/'
29
        );
30
31
        $loader = new XmlFileLoader(
32
            $container,
33
            new FileLocator(
34
                __DIR__ . '/../Resources/config'
35
            )
36
        );
37
        $loader->load('reader.xml');
38
    }
39
40
}
41