vendor/symfony/doctrine-bridge/Middleware/Debug/Driver.php line 41

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bridge\Doctrine\Middleware\Debug;
  11. use Doctrine\DBAL\Driver as DriverInterface;
  12. use Doctrine\DBAL\Driver\Connection as ConnectionInterface;
  13. use Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware;
  14. use Symfony\Component\Stopwatch\Stopwatch;
  15. /**
  16. * @author Laurent VOULLEMIER <laurent.voullemier@gmail.com>
  17. *
  18. * @internal
  19. */
  20. final class Driver extends AbstractDriverMiddleware
  21. {
  22. private $debugDataHolder;
  23. private $stopwatch;
  24. private $connectionName;
  25. public function __construct(DriverInterface $driver, DebugDataHolder $debugDataHolder, ?Stopwatch $stopwatch, string $connectionName)
  26. {
  27. parent::__construct($driver);
  28. $this->debugDataHolder = $debugDataHolder;
  29. $this->stopwatch = $stopwatch;
  30. $this->connectionName = $connectionName;
  31. }
  32. public function connect(array $params): ConnectionInterface
  33. {
  34. $connection = parent::connect($params);
  35. if ('void' !== (string) (new \ReflectionMethod(DriverInterface\Connection::class, 'commit'))->getReturnType()) {
  36. return new DBAL3\Connection(
  37. $connection,
  38. $this->debugDataHolder,
  39. $this->stopwatch,
  40. $this->connectionName
  41. );
  42. }
  43. return new Connection(
  44. $connection,
  45. $this->debugDataHolder,
  46. $this->stopwatch,
  47. $this->connectionName
  48. );
  49. }
  50. }