1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DoctrineORMModule\Service; |
4
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Migrations\Configuration\Configuration; |
6
|
|
|
use DoctrineModule\Service\AbstractFactory; |
7
|
|
|
use Interop\Container\ContainerInterface; |
8
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
9
|
|
|
use Symfony\Component\Console\Output\ConsoleOutput; |
10
|
|
|
use Doctrine\DBAL\Migrations\OutputWriter; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* DBAL Connection ServiceManager factory |
14
|
|
|
* |
15
|
|
|
* @license MIT |
16
|
|
|
* @link http://www.doctrine-project.org/ |
17
|
|
|
* @author Marco Pivetta <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
class MigrationsConfigurationFactory extends AbstractFactory |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* {@inheritDoc} |
23
|
|
|
* |
24
|
|
|
* @return \Doctrine\DBAL\Migrations\Configuration\Configuration |
25
|
|
|
*/ |
26
|
18 |
|
public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
27
|
|
|
{ |
28
|
18 |
|
$name = $this->getName(); |
29
|
|
|
/* @var $connection \Doctrine\DBAL\Connection */ |
30
|
18 |
|
$connection = $container->get('doctrine.connection.' . $name); |
31
|
18 |
|
$appConfig = $container->get('config'); |
32
|
18 |
|
$migrationsConfig = $appConfig['doctrine']['migrations_configuration'][$name]; |
33
|
|
|
|
34
|
18 |
|
$output = new ConsoleOutput(); |
35
|
18 |
|
$writer = new OutputWriter(function ($message) use ($output) { |
36
|
|
|
return $output->writeln($message); |
37
|
18 |
|
}); |
38
|
|
|
|
39
|
18 |
|
$configuration = new Configuration($connection, $writer); |
40
|
|
|
|
41
|
18 |
|
$configuration->setName($migrationsConfig['name']); |
42
|
18 |
|
$configuration->setMigrationsDirectory($migrationsConfig['directory']); |
43
|
18 |
|
$configuration->setMigrationsNamespace($migrationsConfig['namespace']); |
44
|
18 |
|
$configuration->setMigrationsTableName($migrationsConfig['table']); |
45
|
18 |
|
$configuration->registerMigrationsFromDirectory($migrationsConfig['directory']); |
46
|
|
|
|
47
|
18 |
|
if (method_exists($configuration, 'setMigrationsColumnName')) { |
48
|
18 |
|
$configuration->setMigrationsColumnName($migrationsConfig['column']); |
49
|
18 |
|
} |
50
|
|
|
|
51
|
18 |
|
if (isset($migrationsConfig['custom_template']) && method_exists($configuration, 'setCustomTemplate')) { |
52
|
|
|
$configuration->setCustomTemplate($migrationsConfig['custom_template']); |
|
|
|
|
53
|
|
|
} |
54
|
|
|
|
55
|
18 |
|
return $configuration; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* {@inheritDoc} |
60
|
|
|
* |
61
|
|
|
* @return \Doctrine\DBAL\Migrations\Configuration\Configuration |
62
|
|
|
*/ |
63
|
18 |
|
public function createService(ServiceLocatorInterface $container) |
64
|
|
|
{ |
65
|
18 |
|
return $this($container, \Doctrine\DBAL\Migrations\Configuration\Configuration::class); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* {@inheritDoc} |
70
|
|
|
*/ |
71
|
|
|
public function getOptionsClass() |
72
|
|
|
{ |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.