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