1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-01-17 13:28:35 +01:00

added possibility to provide an entity manager in doctrine collector

This commit is contained in:
maximebf 2013-08-13 12:09:50 +10:00
parent a1e2a90683
commit 63c88cc67e

View File

@ -12,6 +12,8 @@ namespace DebugBar\Bridge;
use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable;
use DebugBar\DebugBarException;
use Doctrine\ORM\EntityManager;
use Doctrine\DBAL\Logging\DebugStack;
/**
@ -31,9 +33,15 @@ class DoctrineCollector extends DataCollector implements Renderable
{
protected $debugStack;
public function __construct(DebugStack $debugStack)
public function __construct($debugStackOrEntityManager)
{
$this->debugStack = $debugStack;
if ($debugStackOrEntityManager instanceof EntityManager) {
$debugStackOrEntityManager = $debugStackOrEntityManager->getConnection()->getConfiguration()->getSQLLogger();
}
if (!($debugStackOrEntityManager instanceof DebugStack)) {
throw new DebugBarException("'DoctrineCollector' requires an 'EntityManager' or 'DebugStack' object");
}
$this->debugStack = $debugStackOrEntityManager;
}
/**