get Doctrine connection from DIC
This commit is contained in:
parent
f54713acb8
commit
16c524bd1a
@ -41,6 +41,7 @@ use Monolog\Logger;
|
|||||||
use OxidEsales\Eshop\Core\Controller\BaseController;
|
use OxidEsales\Eshop\Core\Controller\BaseController;
|
||||||
use OxidEsales\Eshop\Core\Registry;
|
use OxidEsales\Eshop\Core\Registry;
|
||||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||||
|
use OxidEsales\EshopCommunity\Internal\Framework\Database\ConnectionProviderInterface;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRenderer;
|
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRenderer;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridge;
|
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridge;
|
||||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridgeInterface;
|
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridgeInterface;
|
||||||
@ -95,16 +96,15 @@ class DebugBarComponent extends BaseController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return DoctrineCollector
|
* @return DoctrineCollector
|
||||||
* @throws ReflectionException
|
* @throws ContainerExceptionInterface
|
||||||
* @throws DebugBarException
|
* @throws DebugBarException
|
||||||
* @throws DatabaseConnectionException
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function getDoctrineCollector(): DoctrineCollector
|
public function getDoctrineCollector(): DoctrineCollector
|
||||||
{
|
{
|
||||||
$db = DatabaseProvider::getDb();
|
|
||||||
$debugStack = new DebugStack();
|
|
||||||
/** @var Connection $connection */
|
/** @var Connection $connection */
|
||||||
$connection = $this->getNonPublicProperty($db, 'connection');
|
$connection = ContainerFactory::getInstance()->getContainer()->get(ConnectionProviderInterface::class)->get();
|
||||||
|
$debugStack = new DebugStack();
|
||||||
$connection->getConfiguration()->setSQLLogger($debugStack);
|
$connection->getConfiguration()->setSQLLogger($debugStack);
|
||||||
return new DoctrineCollector($debugStack);
|
return new DoctrineCollector($debugStack);
|
||||||
}
|
}
|
||||||
@ -175,21 +175,6 @@ class DebugBarComponent extends BaseController
|
|||||||
return oxNew(OxidVersionCollector::class);
|
return oxNew(OxidVersionCollector::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param object $object
|
|
||||||
* @param string $propName
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
protected function getNonPublicProperty(object $object, string $propName)
|
|
||||||
{
|
|
||||||
$reflection = new ReflectionClass($object);
|
|
||||||
$property = $reflection->getProperty($propName);
|
|
||||||
$property->setAccessible(true);
|
|
||||||
return $property->getValue($object);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param DebugBar $debugbar
|
* @param DebugBar $debugbar
|
||||||
* @return void
|
* @return void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user