diff --git a/config/zfsnapphpdebugbar.config.php b/config/zfsnapphpdebugbar.config.php index 97c094b..bd49ead 100644 --- a/config/zfsnapphpdebugbar.config.php +++ b/config/zfsnapphpdebugbar.config.php @@ -13,7 +13,10 @@ 'zend-db-adapter-service-name' => Zend\Db\Adapter\Adapter::class, // ServiceManager service keys to inject collectors // http://phpdebugbar.com/docs/data-collectors.html - 'collectors' => [], + 'collectors' => [ + // uncomment if you use Doctrine ORM + //DebugBar\Bridge\DoctrineCollector::class, + ], // ServiceManager service key to inject storage // http://phpdebugbar.com/docs/storage.html 'storage' => null, @@ -25,6 +28,13 @@ 'factories' => [ 'debugbar' => ZfSnapPhpDebugBar\Service\PhpDebugBarFactory::class, ZfSnapPhpDebugBar\Log\Writer\PhpDebugBar::class => ZfSnapPhpDebugBar\Log\Writer\PhpDebugBarFactory::class, + DebugBar\Bridge\DoctrineCollector::class => ZfSnapPhpDebugBar\Collector\DoctrineCollectorFactory::class, + ], + 'delegators' => [ + // uncomment if you use Doctrine ORM + //'doctrine.configuration.orm_default' => [ + // ZfSnapPhpDebugBar\Delegator\DoctrineConfigurationDelegatorFactory::class, + //], ], ], 'controllers' => [ diff --git a/src/Collector/DoctrineCollectorFactory.php b/src/Collector/DoctrineCollectorFactory.php new file mode 100644 index 0000000..a7824d3 --- /dev/null +++ b/src/Collector/DoctrineCollectorFactory.php @@ -0,0 +1,22 @@ +get('doctrine.configuration.orm_default')->getSQLLogger(); + return new DoctrineCollector($debugStack); + } + + public function createService(ServiceLocatorInterface $serviceLocator) + { + return $this($serviceLocator, DoctrineCollector::class); + } +} diff --git a/src/Delegator/DoctrineConfigurationDelegatorFactory.php b/src/Delegator/DoctrineConfigurationDelegatorFactory.php new file mode 100644 index 0000000..eb28f37 --- /dev/null +++ b/src/Delegator/DoctrineConfigurationDelegatorFactory.php @@ -0,0 +1,23 @@ +setSQLLogger(new DebugStack); + return $doctrineConfiguration; + } + + public function createDelegatorWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName, $callback) + { + return $this($serviceLocator, $requestedName, $callback); + } +}