Skip to content

Commit

Permalink
Corrected event to attach Doctrine SQL Logger to ZendDeveloperTools
Browse files Browse the repository at this point in the history
  • Loading branch information
TomHAnderson committed Apr 15, 2018
1 parent 2205a3c commit d0ff7aa
Showing 1 changed file with 13 additions and 23 deletions.
36 changes: 13 additions & 23 deletions src/DoctrineORMModule/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

use Interop\Container\ContainerInterface;
use Zend\EventManager\EventInterface;
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
use Zend\ModuleManager\Feature\ControllerProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\ModuleManager\Feature\DependencyIndicatorInterface;
use Zend\ModuleManager\ModuleManagerInterface;
use DoctrineORMModule\CliConfigurator;
use ZendDeveloperTools\ProfilerEvent;

/**
* Base module for Doctrine ORM.
Expand All @@ -20,7 +20,6 @@
* @author Marco Pivetta <[email protected]>
*/
class Module implements
BootstrapListenerInterface,
ControllerProviderInterface,
ConfigProviderInterface,
DependencyIndicatorInterface
Expand All @@ -46,28 +45,19 @@ function (EventInterface $event) {
},
1
);
}

/**
* {@inheritDoc}
*/
public function onBootstrap(EventInterface $event)
{
/* @var $application \Zend\Mvc\Application */
$application = $event->getTarget();

/* @var $container ContainerInterface */
$container = $application->getServiceManager();

$events = $application->getEventManager();

// Initialize logger collector once the profiler is initialized itself
$events->attach(
'profiler_init',
function () use ($container) {
$container->get('doctrine.sql_logger_collector.orm_default');
}
);
// Initialize logger collector in ZendDeveloperTools
if (class_exists(ProfilerEvent::class)) {
$manager
->getEventManager()
->attach(
ProfilerEvent::EVENT_PROFILER_INIT,
function ($event) {
$container = $event->getTarget()->getParam('ServiceManager');
$container->get('doctrine.sql_logger_collector.orm_default');
}
);
}
}

/**
Expand Down

0 comments on commit d0ff7aa

Please sign in to comment.