1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Abacaphiliac\DoctrineORMDiagnosticsModule; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Application; |
6
|
|
|
use Zend\EventManager\EventInterface; |
7
|
|
|
use Zend\ModuleManager\Feature\ConfigProviderInterface; |
8
|
|
|
use Zend\ModuleManager\Feature\DependencyIndicatorInterface; |
9
|
|
|
use Zend\ModuleManager\Feature\InitProviderInterface; |
10
|
|
|
use Zend\ModuleManager\ModuleManagerInterface; |
11
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
12
|
|
|
|
13
|
|
|
class Module implements ConfigProviderInterface, DependencyIndicatorInterface, InitProviderInterface |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* Returns configuration to merge with application configuration |
17
|
|
|
* |
18
|
|
|
* @return array|\Traversable |
19
|
|
|
*/ |
20
|
3 |
|
public function getConfig() |
21
|
|
|
{ |
22
|
3 |
|
return require dirname(dirname(__DIR__)) . '/config/module.config.php'; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Expected to return an array of modules on which the current one depends on |
27
|
|
|
* |
28
|
|
|
* @return array |
29
|
|
|
*/ |
30
|
3 |
|
public function getModuleDependencies() |
31
|
|
|
{ |
32
|
|
|
return [ |
33
|
3 |
|
'DoctrineModule', |
34
|
3 |
|
'DoctrineORMModule', |
35
|
3 |
|
'ZFTool', |
36
|
3 |
|
]; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param ModuleManagerInterface $manager |
41
|
|
|
*/ |
42
|
2 |
|
public function init(ModuleManagerInterface $manager) |
43
|
|
|
{ |
44
|
2 |
|
$events = $manager->getEventManager(); |
45
|
2 |
|
$sharedEventManager = $events->getSharedManager(); |
46
|
2 |
|
$sharedEventManager->attach('doctrine', 'loadCli.post', [$this, 'initializeConsole']); |
47
|
2 |
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Initialize the console with additional commands from (optionally) doctrine\migrations |
51
|
|
|
* @param EventInterface $event |
52
|
|
|
* @return bool |
53
|
|
|
* @throws \Zend\ServiceManager\Exception\ServiceNotFoundException |
54
|
|
|
*/ |
55
|
5 |
|
public function initializeConsole(EventInterface $event) |
56
|
|
|
{ |
57
|
5 |
|
$cli = $event->getTarget(); |
58
|
5 |
|
if (!$cli instanceof Application) { |
59
|
1 |
|
return false; |
60
|
|
|
} |
61
|
|
|
|
62
|
4 |
|
$serviceLocator = $event->getParam('ServiceManager'); |
63
|
4 |
|
if (!$serviceLocator instanceof ServiceLocatorInterface) { |
64
|
1 |
|
return false; |
65
|
|
|
} |
66
|
|
|
|
67
|
3 |
|
if (class_exists('Doctrine\DBAL\Migrations\Tools\Console\Command\UpToDateCommand')) { |
68
|
3 |
|
$upToDateCommand = $serviceLocator->get('doctrine.migrations_cmd.uptodate'); |
69
|
|
|
|
70
|
3 |
|
$cli->addCommands([ |
|
|
|
|
71
|
3 |
|
$upToDateCommand, |
72
|
3 |
|
]); |
73
|
3 |
|
} |
74
|
|
|
|
75
|
3 |
|
return true; |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: