DdrRestExtension::load()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 13
cts 13
cp 1
rs 9.568
c 0
b 0
f 0
cc 4
nc 2
nop 2
crap 4
1
<?php
2
3
namespace Dontdrinkandroot\RestBundle\DependencyInjection;
4
5
use Symfony\Component\Config\FileLocator;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Loader;
8
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
9
10
/**
11
 * @author Philip Washington Sorst <[email protected]>
12
 */
13
class DdrRestExtension extends Extension
14
{
15
    const ACCESS_TOKEN_CLASS = 'access_token_class';
16
    const AUTHENTICATION_PROVIDER_KEY = 'authentication_provider_key';
17
18
    /**
19
     * {@inheritdoc}
20
     */
21 12
    public function load(array $configs, ContainerBuilder $container)
22
    {
23 12
        $configuration = new Configuration();
24 12
        $config = $this->processConfiguration($configuration, $configs);
25
26 12
        $container->setParameter('ddr_rest.paths', $config['paths']);
27
28 12
        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
29 12
        $loader->load('services.xml');
30
31 12
        $directories = [];
32
        #$directories['Dontdrinkandroot\RestBundle'] = realpath(__DIR__ . '/../config/rest/');
33 12
        if (array_key_exists('metadata', $config) && array_key_exists('directories', $config['metadata'])) {
34 12
            foreach ($config['metadata']['directories'] as $directory) {
35 12
                $directories[$directory['namespace_prefix']] = $directory['path'];
36
            }
37
        }
38
39
        $container
40 12
            ->getDefinition('ddr_rest.metadata.file_locator')
41 12
            ->setArguments([$directories]);
42 12
    }
43
}
44