From 7f40b03986de525ad768f3562aa685f6c9791dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bar=C3=A1=C5=A1ek?= Date: Tue, 19 Oct 2021 14:42:34 +0200 Subject: [PATCH] Extension: Fix DIC support. --- src/DatabaseExtension.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/DatabaseExtension.php b/src/DatabaseExtension.php index 0ea775a..add4a0d 100644 --- a/src/DatabaseExtension.php +++ b/src/DatabaseExtension.php @@ -25,6 +25,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Logging\LoggerChain; use Doctrine\DBAL\Portability\Connection as PortabilityConnection; +use Doctrine\DBAL\Tools\Console\ConnectionProvider\SingleConnectionProvider; use Nette\DI\CompilerExtension; use Nette\DI\ContainerBuilder; use Nette\DI\Definitions\ServiceDefinition; @@ -322,7 +323,9 @@ private function loadDoctrineConfiguration(): void if ($config['configuration']['sqlLogger'] !== null) { // SqlLogger (append to chain) $loggers[] = '@' . $config['configuration']['sqlLogger']; } - $loggers[] = $builder->getDefinition('doctrine.queryPanel'); + if ($builder->hasDefinition('doctrine.queryPanel')) { + $loggers[] = $builder->getDefinition('doctrine.queryPanel'); + } $logger->setArgument('loggers', $loggers); if ($config['configuration']['resultCacheImpl'] !== null) { // ResultCacheImpl @@ -446,6 +449,9 @@ private function loadConnectionConfiguration(): void $builder->getDefinitionByType(EventManager::class), ] ); + + $builder->addDefinition($this->prefix('singleConnectionProvider')) + ->setFactory(SingleConnectionProvider::class); }