Completed
Push — standalone ( fe4753...a7b79f )
by Philip
03:48
created

DdrRestExtension::load()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 28
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 17
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 17
cts 17
cp 1
rs 8.439
c 0
b 0
f 0
cc 5
eloc 17
nc 4
nop 2
crap 5
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
class DdrRestExtension extends Extension
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 4
    public function load(array $configs, ContainerBuilder $container)
16
    {
17 4
        $configuration = new Configuration();
18 4
        $config = $this->processConfiguration($configuration, $configs);
19
20 4
        $container->setParameter('ddr.rest.paths', $config['paths']);
21
22 4
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
23 4
        $loader->load('services.yml');
24
25 4
        $directories = [];
26 4
        if (array_key_exists('metadata', $config) && array_key_exists('directories', $config['metadata'])) {
27 2
            foreach ($config['metadata']['directories'] as $directory) {
28 2
                $directories[$directory['namespace_prefix']] = $directory['path'];
29
            }
30
        }
31
32
        $container
33 4
            ->getDefinition('ddr_rest.metadata.file_locator')
34 4
            ->setArguments([$directories]);
35
36 4
        if (null !== $config['access_token_class']) {
37 2
            $container->setParameter('ddr.rest.access_token_class', $config['access_token_class']);
38 2
            $container->setParameter('ddr.rest.authentication_provider_key', $config['authentication_provider_key']);
39
40 2
            $loader->load('services_security.yml');
41
        }
42 4
    }
43
}
44