1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DoctrineORMModule; |
4
|
|
|
|
5
|
|
|
use DoctrineORMModule\Listener\PostCliLoadListener; |
6
|
|
|
use Interop\Container\ContainerInterface; |
7
|
|
|
use Zend\EventManager\EventInterface; |
8
|
|
|
use Zend\ModuleManager\Feature\BootstrapListenerInterface; |
9
|
|
|
use Zend\ModuleManager\Feature\ControllerProviderInterface; |
10
|
|
|
use Zend\ModuleManager\Feature\ConfigProviderInterface; |
11
|
|
|
use Zend\ModuleManager\Feature\DependencyIndicatorInterface; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Base module for Doctrine ORM. |
15
|
|
|
* |
16
|
|
|
* @license MIT |
17
|
|
|
* @link www.doctrine-project.org |
18
|
|
|
* @author Kyle Spraggs <[email protected]> |
19
|
|
|
* @author Marco Pivetta <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
class Module implements |
22
|
|
|
BootstrapListenerInterface, |
23
|
|
|
ControllerProviderInterface, |
24
|
|
|
ConfigProviderInterface, |
25
|
|
|
DependencyIndicatorInterface |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* {@inheritDoc} |
29
|
|
|
*/ |
30
|
|
|
public function onBootstrap(EventInterface $event) |
31
|
|
|
{ |
32
|
|
|
/* @var $application \Zend\Mvc\Application */ |
33
|
|
|
$application = $event->getTarget(); |
34
|
|
|
/* @var $container ContainerInterface */ |
35
|
|
|
$container = $application->getServiceManager(); |
36
|
|
|
|
37
|
|
|
$events = $application->getEventManager(); |
38
|
|
|
|
39
|
|
|
// Initialize logger collector once the profiler is initialized itself |
40
|
|
|
$events->attach( |
41
|
|
|
'profiler_init', |
42
|
|
|
function () use ($container) { |
43
|
|
|
$container->get('doctrine.sql_logger_collector.orm_default'); |
44
|
|
|
} |
45
|
|
|
); |
46
|
|
|
|
47
|
|
|
/* @var $postCliLoadListener PostCliLoadListener */ |
48
|
|
|
$postCliLoadListener = $container->get(PostCliLoadListener::class); |
49
|
|
|
$postCliLoadListener->attach($events); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* {@inheritDoc} |
54
|
|
|
*/ |
55
|
72 |
|
public function getConfig() |
56
|
|
|
{ |
57
|
72 |
|
return include __DIR__ . '/../../config/module.config.php'; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* {@inheritDoc} |
62
|
|
|
*/ |
63
|
72 |
|
public function getControllerConfig() |
64
|
|
|
{ |
65
|
72 |
|
return include __DIR__ . '/../../config/controllers.config.php'; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* {@inheritDoc} |
70
|
|
|
*/ |
71
|
72 |
|
public function getModuleDependencies() |
72
|
|
|
{ |
73
|
72 |
|
return ['DoctrineModule']; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|