Completed
Pull Request — master (#265)
by Chris
04:46 queued 01:41
created

configureSchemaProvider()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 2
rs 10
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
        $this->configureSchemaProvider($config, $container);
39 2
    }
40
41
    /**
42
     * Returns the base path for the XSD files.
43
     *
44
     * @return string The XSD base path
45
     */
46
    public function getXsdValidationBasePath() : string
47
    {
48
        return __DIR__ . '/../Resources/config/schema';
49
    }
50
51
    public function getNamespace() : string
52
    {
53
        return 'http://symfony.com/schema/dic/doctrine/migrations';
54
    }
55
56
    /**
57
     * @param string[][] $configs
58
     */
59 2
    private function configureSchemaProvider(array $config, ContainerBuilder $container) : void
0 ignored issues
show
introduced by
Method \Doctrine\Bundle\MigrationsBundle\DependencyInjection\DoctrineMigrationsExtension::configureSchemaProvider() does not have @param annotation for its traversable parameter $config.
Loading history...
60
    {
61 2
        if (! $config['schema_provider']) {
62 1
            return;
63
        }
64
65 1
        $diffCommand = $container->findDefinition('doctrine_migrations.diff_command');
66 1
        $diffCommand->setArgument(0, new Reference($config['schema_provider']));
67 1
    }
68
}
69