1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DoctrineMigrationsModule\Service; |
4
|
|
|
|
5
|
|
|
use Interop\Container\ContainerInterface; |
6
|
|
|
use Zend\ServiceManager\FactoryInterface; |
7
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
8
|
|
|
use DoctrineMigrationsModule\Migrations\Configuration; |
9
|
|
|
|
10
|
|
|
class ConfigurationFactory implements FactoryInterface |
|
|
|
|
11
|
|
|
{ |
12
|
|
|
public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
13
|
|
|
{ |
14
|
|
|
// Get config. |
15
|
|
|
$config = $container->get('configuration'); |
16
|
|
|
$config = $config['doctrine']['migrations']; |
17
|
|
|
|
18
|
|
View Code Duplication |
if (isset($config['connection']) && $container->has($config['connection'])) { |
|
|
|
|
19
|
|
|
$connection = $container->get($config['connection']); |
20
|
|
|
} else { |
21
|
|
|
$connection = $container->get('doctrine.connection.orm_default'); |
22
|
|
|
} |
23
|
|
|
unset($config['connection']); |
24
|
|
|
|
25
|
|
View Code Duplication |
if (isset($config['output_writer']) && $container->has($config['output_writer'])) { |
|
|
|
|
26
|
|
|
$outputWriter = $container->get($config['output_writer']); |
27
|
|
|
} else { |
28
|
|
|
$outputWriter = null; |
29
|
|
|
} |
30
|
|
|
unset($config['output_writer']); |
31
|
|
|
|
32
|
|
|
$configuration = new Configuration($connection, $outputWriter); |
33
|
|
|
|
34
|
|
|
foreach ($config as $key => $value) { |
35
|
|
|
$setter = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))); |
36
|
|
|
if (!method_exists($configuration, $setter)) { |
37
|
|
|
continue; |
38
|
|
|
} |
39
|
|
|
$configuration->{$setter}($value); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
return $configuration; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Create service |
47
|
|
|
* |
48
|
|
|
* @param ServiceLocatorInterface $serviceLocator |
49
|
|
|
* @return mixed |
50
|
|
|
*/ |
51
|
|
|
public function createService(ServiceLocatorInterface $serviceLocator) |
52
|
|
|
{ |
53
|
|
|
$config = $serviceLocator->get('configuration'); |
|
|
|
|
54
|
|
|
|
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.