|
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 |
|
|
|
|
|
|
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
|
|
|
|