|
11 | 11 |
|
12 | 12 | use Doctrine\Common\EventManager; |
13 | 13 | use Doctrine\DBAL\DriverManager; |
| 14 | +use Doctrine\DBAL\Logging\Middleware as LoggingMiddleware; |
14 | 15 | use Doctrine\Persistence\Mapping\Driver\MappingDriver; |
15 | 16 | use Doctrine\Persistence\ObjectRepository; |
16 | | -use Doctrine\DBAL\Logging\DebugStack; |
17 | 17 | use Doctrine\ORM\EntityManager; |
18 | 18 | use Doctrine\ORM\Events; |
19 | 19 | use Doctrine\ORM\Mapping\ClassMetadataFactory; |
@@ -197,7 +197,7 @@ private function __construct($entityClasses, ?ConnectionConfiguration $connectio |
197 | 197 | } |
198 | 198 | $this->entityClasses = $entityClasses; |
199 | 199 | $this->connectionConfiguration = $connectionConfiguration; |
200 | | - $this->queryLogger = new DebugStack(); |
| 200 | + $this->queryLogger = new QueryLogger(); |
201 | 201 | $this->namingStrategy = new DefaultNamingStrategy(); |
202 | 202 | $this->mappingDriver = $mappingDriver; |
203 | 203 | $this->resolveTargetListener = new ResolveTargetEntityListener(); |
@@ -242,13 +242,7 @@ public function getRepository($classNameOrEntity) |
242 | 242 | */ |
243 | 243 | public function getQueries() |
244 | 244 | { |
245 | | - return array_map(function (array $queryData) { |
246 | | - return new Query( |
247 | | - $queryData['sql'], |
248 | | - (isset($queryData['params']) ? $queryData['params'] : array()), |
249 | | - $queryData['executionMS'] |
250 | | - ); |
251 | | - }, $this->queryLogger->queries); |
| 245 | + return $this->queryLogger->getQueries(); |
252 | 246 | } |
253 | 247 |
|
254 | 248 | /** |
@@ -332,7 +326,9 @@ protected function createEntityManager() |
332 | 326 | { |
333 | 327 | $configFactory = new ConfigurationFactory($this->mappingDriver); |
334 | 328 | $config = $configFactory->createFor($this->entityClasses); |
335 | | - $config->setSQLLogger($this->queryLogger); |
| 329 | + $middlewares = $config->getMiddlewares(); |
| 330 | + $middlewares[] = new LoggingMiddleware($this->queryLogger); |
| 331 | + $config->setMiddlewares($middlewares); |
336 | 332 | $config->setNamingStrategy($this->namingStrategy); |
337 | 333 |
|
338 | 334 | if ($this->connectionConfiguration instanceof ExistingConnectionConfiguration) { |
|
0 commit comments