Skip to content

Commit d0ff7aa

Browse files
committed
Corrected event to attach Doctrine SQL Logger to ZendDeveloperTools
1 parent 2205a3c commit d0ff7aa

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

src/DoctrineORMModule/Module.php

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
use Interop\Container\ContainerInterface;
66
use Zend\EventManager\EventInterface;
7-
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
87
use Zend\ModuleManager\Feature\ControllerProviderInterface;
98
use Zend\ModuleManager\Feature\ConfigProviderInterface;
109
use Zend\ModuleManager\Feature\DependencyIndicatorInterface;
1110
use Zend\ModuleManager\ModuleManagerInterface;
1211
use DoctrineORMModule\CliConfigurator;
12+
use ZendDeveloperTools\ProfilerEvent;
1313

1414
/**
1515
* Base module for Doctrine ORM.
@@ -20,7 +20,6 @@
2020
* @author Marco Pivetta <ocramius@gmail.com>
2121
*/
2222
class Module implements
23-
BootstrapListenerInterface,
2423
ControllerProviderInterface,
2524
ConfigProviderInterface,
2625
DependencyIndicatorInterface
@@ -46,28 +45,19 @@ function (EventInterface $event) {
4645
},
4746
1
4847
);
49-
}
50-
51-
/**
52-
* {@inheritDoc}
53-
*/
54-
public function onBootstrap(EventInterface $event)
55-
{
56-
/* @var $application \Zend\Mvc\Application */
57-
$application = $event->getTarget();
58-
59-
/* @var $container ContainerInterface */
60-
$container = $application->getServiceManager();
61-
62-
$events = $application->getEventManager();
6348

64-
// Initialize logger collector once the profiler is initialized itself
65-
$events->attach(
66-
'profiler_init',
67-
function () use ($container) {
68-
$container->get('doctrine.sql_logger_collector.orm_default');
69-
}
70-
);
49+
// Initialize logger collector in ZendDeveloperTools
50+
if (class_exists(ProfilerEvent::class)) {
51+
$manager
52+
->getEventManager()
53+
->attach(
54+
ProfilerEvent::EVENT_PROFILER_INIT,
55+
function ($event) {
56+
$container = $event->getTarget()->getParam('ServiceManager');
57+
$container->get('doctrine.sql_logger_collector.orm_default');
58+
}
59+
);
60+
}
7161
}
7262

7363
/**

0 commit comments

Comments
 (0)