1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
14
|
|
|
* |
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
16
|
|
|
* and is licensed under the MIT license. For more information, see |
17
|
|
|
* <http://www.doctrine-project.org>. |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace DoctrineORMModule; |
21
|
|
|
|
22
|
|
|
use Psr\Container\ContainerInterface; |
23
|
|
|
use Zend\EventManager\EventInterface; |
24
|
|
|
use Zend\ModuleManager\Feature\BootstrapListenerInterface; |
25
|
|
|
use Zend\ModuleManager\Feature\ControllerProviderInterface; |
26
|
|
|
use Zend\ModuleManager\Feature\ConfigProviderInterface; |
27
|
|
|
use Zend\ModuleManager\Feature\DependencyIndicatorInterface; |
28
|
|
|
use Zend\ModuleManager\ModuleManagerInterface; |
29
|
|
|
use Symfony\Component\Console\Application; |
30
|
|
|
use DoctrineORMModule\Listener\PostCliLoadListener; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Base module for Doctrine ORM. |
34
|
|
|
* |
35
|
|
|
* @license MIT |
36
|
|
|
* @link www.doctrine-project.org |
37
|
|
|
* @author Kyle Spraggs <[email protected]> |
38
|
|
|
* @author Marco Pivetta <[email protected]> |
39
|
|
|
*/ |
40
|
|
|
class Module implements |
41
|
|
|
ControllerProviderInterface, |
42
|
|
|
ConfigProviderInterface, |
43
|
|
|
DependencyIndicatorInterface, |
44
|
|
|
BootstrapListenerInterface |
45
|
|
|
{ |
46
|
|
|
/** |
47
|
|
|
* {@inheritDoc} |
48
|
|
|
*/ |
49
|
|
|
public function getConfig() |
50
|
|
|
{ |
51
|
|
|
return include __DIR__ . '/../../config/module.config.php'; |
52
|
|
|
} |
53
|
72 |
|
|
54
|
|
|
/** |
55
|
72 |
|
* {@inheritDoc} |
56
|
|
|
*/ |
57
|
72 |
|
public function getControllerConfig() |
58
|
72 |
|
{ |
59
|
|
|
return include __DIR__ . '/../../config/controllers.config.php'; |
60
|
|
|
} |
61
|
|
|
|
62
|
72 |
|
/** |
63
|
72 |
|
* {@inheritDoc} |
64
|
72 |
|
*/ |
65
|
|
|
public function getModuleDependencies() |
66
|
|
|
{ |
67
|
|
|
return ['DoctrineModule']; |
68
|
|
|
} |
69
|
72 |
|
|
70
|
|
|
/** |
71
|
72 |
|
* @param EventInterface $event |
72
|
|
|
* @throws \Psr\Container\ContainerExceptionInterface |
73
|
|
|
* @throws \Psr\Container\NotFoundExceptionInterface |
74
|
|
|
*/ |
75
|
|
|
public function onBootstrap(EventInterface $event) |
76
|
|
|
{ |
77
|
72 |
|
/* @var $application \Zend\Mvc\Application */ |
78
|
|
|
$application = $event->getTarget(); |
79
|
72 |
|
/* @var $container ContainerInterface */ |
80
|
|
|
$container = $application->getServiceManager(); |
81
|
|
|
|
82
|
|
|
$events = $application->getEventManager(); |
83
|
|
|
|
84
|
|
|
// Initialize logger collector once the profiler is initialized itself |
85
|
72 |
|
$events->attach( |
86
|
|
|
'profiler_init', |
87
|
72 |
|
function () use ($container) { |
88
|
|
|
$container->get('doctrine.sql_logger_collector.orm_default'); |
89
|
|
|
} |
90
|
|
|
); |
91
|
|
|
|
92
|
|
|
/* @var $postCliLoadListener PostCliLoadListener */ |
93
|
|
|
$postCliLoadListener = $container->get(PostCliLoadListener::class); |
94
|
|
|
$postCliLoadListener->attach($events); |
95
|
|
|
|
96
|
|
|
/* @var $doctrineCli Application */ |
97
|
18 |
|
$doctrineCli = $container->get('doctrine.cli'); |
98
|
|
|
|
99
|
|
|
$eventDispatcher = $container->get('doctrine.cli.event_dispatcher'); |
100
|
18 |
|
$doctrineCli->setDispatcher($eventDispatcher); |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|