-
-
Notifications
You must be signed in to change notification settings - Fork 447
/
DebugMiddleware.php
33 lines (27 loc) · 1.03 KB
/
DebugMiddleware.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
namespace Doctrine\Bundle\DoctrineBundle\Middleware;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\Middleware;
use Symfony\Bridge\Doctrine\Middleware\Debug\DebugDataHolder;
use Symfony\Bridge\Doctrine\Middleware\Debug\Driver;
use Symfony\Component\Stopwatch\Stopwatch;
class DebugMiddleware implements Middleware, ConnectionNameAwareInterface
{
private DebugDataHolder $debugDataHolder;
private ?Stopwatch $stopwatch;
private string $connectionName = 'default';
public function __construct(DebugDataHolder $debugDataHolder, ?Stopwatch $stopwatch)
{
$this->debugDataHolder = $debugDataHolder;
$this->stopwatch = $stopwatch;
}
public function setConnectionName(string $name): void
{
$this->connectionName = $name;
}
public function wrap(DriverInterface $driver): DriverInterface
{
/** @psalm-suppress InternalClass,InternalMethod */
return new Driver($driver, $this->debugDataHolder, $this->stopwatch, $this->connectionName);
}
}