Completed
Push — master ( 28d70e...e6830e )
by Philip
18:57
created

DdrRestExtension::loadSecurityConfig()   C

Complexity

Conditions 7
Paths 3

Size

Total Lines 27
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 9.1535

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 11
cts 17
cp 0.6471
rs 6.7272
c 0
b 0
f 0
cc 7
eloc 17
nc 3
nop 3
crap 9.1535
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\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
29 12
        $loader->load('services.yml');
30
31 12
        $directories = [];
32 12
        $directories['Dontdrinkandroot\RestBundle'] = realpath(__DIR__ . '/../Resources/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