-
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Doctrine\Bundle\DoctrineBundle\Middleware; | ||
|
||
use Doctrine\DBAL\Driver; | ||
use Doctrine\DBAL\Driver\Connection as DriverConnection; | ||
use Doctrine\DBAL\Driver\Middleware; | ||
use Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware; | ||
use Symfony\Bridge\Doctrine\ConnectionTimingWeakMap; | ||
|
||
class ConnectionKeepAlive implements Middleware, ConnectionNameAwareInterface | ||
{ | ||
private ConnectionTimingWeakMap $connectionTimingWeakMap; | ||
Check failure on line 13 in Middleware/ConnectionKeepAlive.php GitHub Actions / Static Analysis with PsalmUndefinedClass
|
||
private string $connectionName; | ||
|
||
public function __construct(ConnectionTimingWeakMap $connectionTimingWeakMap, string $connectionName = 'default') | ||
Check failure on line 16 in Middleware/ConnectionKeepAlive.php GitHub Actions / Static Analysis with PsalmUndefinedClass
|
||
{ | ||
$this->connectionName = $connectionName; | ||
$this->connectionTimingWeakMap = $connectionTimingWeakMap; | ||
} | ||
|
||
public function setConnectionName(string $name): void | ||
{ | ||
$this->connectionName = $name; | ||
} | ||
|
||
public function wrap(Driver $driver): Driver | ||
{ | ||
return new class($driver, $this->connectionTimingWeakMap, $this->connectionName) extends AbstractDriverMiddleware { | ||
private Driver $driver; | ||
private ConnectionTimingWeakMap $connectionTimingWeakMap; | ||
Check failure on line 31 in Middleware/ConnectionKeepAlive.php GitHub Actions / Static Analysis with PsalmUndefinedClass
|
||
private string $connectionName; | ||
|
||
public function __construct(Driver $driver, ConnectionTimingWeakMap $connectionTimingWeakMap, string $connectionName = 'default') | ||
Check failure on line 34 in Middleware/ConnectionKeepAlive.php GitHub Actions / Static Analysis with PsalmUndefinedClass
|
||
{ | ||
$this->connectionName = $connectionName; | ||
$this->connectionTimingWeakMap = $connectionTimingWeakMap; | ||
$this->driver = $driver; | ||
|
||
parent::__construct($driver); | ||
} | ||
|
||
public function connect(array $params): DriverConnection | ||
Check failure on line 43 in Middleware/ConnectionKeepAlive.php GitHub Actions / Coding Standards / Coding Standards (8.2)
|
||
{ | ||
$connection = parent::connect($params); | ||
$this->connectionTimingWeakMap->setTimingPerConnection($connection, $this->connectionName); | ||
Check failure on line 46 in Middleware/ConnectionKeepAlive.php GitHub Actions / Static Analysis with PsalmUndefinedClass
|
||
|
||
return $connection; | ||
} | ||
}; | ||
} | ||
} |