Completed
Pull Request — master (#265)
by Chris
07:07
created

DoctrineMigrationsExtension::load()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 10
nc 4
nop 2
dl 0
loc 18
ccs 11
cts 11
cp 1
crap 3
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Bundle\MigrationsBundle\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\DependencyInjection\Reference;
11
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
12
13
/**
14
 * DoctrineMigrationsExtension.
15
 */
16
class DoctrineMigrationsExtension extends Extension
17
{
18
    /**
19
     * Responds to the migrations configuration parameter.
20
     *
21
     * @param string[][] $configs
22
     */
23 2
    public function load(array $configs, ContainerBuilder $container) : void
24
    {
25 2
        $configuration = new Configuration();
26
27 2
        $config = $this->processConfiguration($configuration, $configs);
28
29 2
        foreach ($config as $key => $value) {
30 2
            $container->setParameter($this->getAlias() . '.' . $key, $value);
31
        }
32
33 2
        $locator = new FileLocator(__DIR__ . '/../Resources/config/');
34 2
        $loader  = new XmlFileLoader($container, $locator);
35
36 2
        $loader->load('services.xml');
37
38 2
        if ($config['schema_provider']) {
0 ignored issues
show
introduced by
Use early exit to reduce code nesting.
Loading history...
39 1
            $diffCommand = $container->findDefinition('doctrine_migrations.diff_command');
40 1
            $diffCommand->setArgument(0, new Reference($config['schema_provider']));
41
        }
42 2
    }
43
44
    /**
45
     * Returns the base path for the XSD files.
46
     *
47
     * @return string The XSD base path
48
     */
49
    public function getXsdValidationBasePath() : string
50
    {
51
        return __DIR__ . '/../Resources/config/schema';
52
    }
53
54
    public function getNamespace() : string
55
    {
56
        return 'http://symfony.com/schema/dic/doctrine/migrations';
57
    }
58
}
59