1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DoctrineORMModule; |
4
|
|
|
|
5
|
|
|
use Interop\Container\ContainerInterface; |
6
|
|
|
use Zend\EventManager\EventInterface; |
7
|
|
|
use Zend\ModuleManager\Feature\ControllerProviderInterface; |
8
|
|
|
use Zend\ModuleManager\Feature\ConfigProviderInterface; |
9
|
|
|
use Zend\ModuleManager\Feature\DependencyIndicatorInterface; |
10
|
|
|
use Zend\ModuleManager\ModuleManagerInterface; |
11
|
|
|
use DoctrineORMModule\CliConfigurator; |
12
|
|
|
use ZendDeveloperTools\ProfilerEvent; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Base module for Doctrine ORM. |
16
|
|
|
* |
17
|
|
|
* @license MIT |
18
|
|
|
* @link www.doctrine-project.org |
19
|
|
|
* @author Kyle Spraggs <[email protected]> |
20
|
|
|
* @author Marco Pivetta <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class Module implements |
23
|
|
|
ControllerProviderInterface, |
24
|
|
|
ConfigProviderInterface, |
25
|
|
|
DependencyIndicatorInterface |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* {@inheritDoc} |
29
|
|
|
*/ |
30
|
72 |
|
public function init(ModuleManagerInterface $manager) |
31
|
|
|
{ |
32
|
|
|
// Initialize the console |
33
|
|
|
$manager |
34
|
72 |
|
->getEventManager() |
35
|
72 |
|
->getSharedManager() |
36
|
72 |
|
->attach( |
37
|
72 |
|
'doctrine', |
38
|
72 |
|
'loadCli.post', |
39
|
72 |
|
function (EventInterface $event) { |
40
|
|
|
$event |
41
|
|
|
->getParam('ServiceManager') |
42
|
|
|
->get(CliConfigurator::class) |
43
|
|
|
->configure($event->getTarget()) |
44
|
|
|
; |
45
|
72 |
|
}, |
46
|
72 |
|
1 |
47
|
|
|
); |
48
|
|
|
|
49
|
|
|
// Initialize logger collector in ZendDeveloperTools |
50
|
72 |
|
if (class_exists(ProfilerEvent::class)) { |
51
|
|
|
$manager |
52
|
72 |
|
->getEventManager() |
53
|
72 |
|
->attach( |
54
|
72 |
|
ProfilerEvent::EVENT_PROFILER_INIT, |
55
|
72 |
|
function ($event) { |
56
|
|
|
$container = $event->getTarget()->getParam('ServiceManager'); |
57
|
|
|
$container->get('doctrine.sql_logger_collector.orm_default'); |
58
|
72 |
|
} |
59
|
|
|
); |
60
|
|
|
} |
61
|
72 |
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* {@inheritDoc} |
65
|
|
|
*/ |
66
|
72 |
|
public function getConfig() |
67
|
|
|
{ |
68
|
72 |
|
return include __DIR__ . '/../../config/module.config.php'; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* {@inheritDoc} |
73
|
|
|
*/ |
74
|
72 |
|
public function getControllerConfig() |
75
|
|
|
{ |
76
|
72 |
|
return include __DIR__ . '/../../config/controllers.config.php'; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* {@inheritDoc} |
81
|
|
|
*/ |
82
|
72 |
|
public function getModuleDependencies() |
83
|
|
|
{ |
84
|
72 |
|
return ['DoctrineModule']; |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|