vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/LoggerChain.php line 10

Open in your IDE?
  1. <?php
  2. namespace Doctrine\DBAL\Logging;
  3. use Doctrine\Deprecations\Deprecation;
  4. /**
  5.  * Chains multiple SQLLogger.
  6.  */
  7. class LoggerChain implements SQLLogger
  8. {
  9.     /** @var SQLLogger[] */
  10.     private $loggers = [];
  11.     /**
  12.      * @param SQLLogger[] $loggers
  13.      */
  14.     public function __construct(array $loggers = [])
  15.     {
  16.         $this->loggers $loggers;
  17.     }
  18.     /**
  19.      * Adds a logger in the chain.
  20.      *
  21.      * @deprecated Inject list of loggers via constructor instead
  22.      *
  23.      * @return void
  24.      */
  25.     public function addLogger(SQLLogger $logger)
  26.     {
  27.         Deprecation::trigger(
  28.             'doctrine/dbal',
  29.             'https://github.com/doctrine/dbal/pull/3572',
  30.             'LoggerChain::addLogger() is deprecated, use LoggerChain constructor instead.'
  31.         );
  32.         $this->loggers[] = $logger;
  33.     }
  34.     /**
  35.      * {@inheritdoc}
  36.      */
  37.     public function startQuery($sql, ?array $params null, ?array $types null)
  38.     {
  39.         foreach ($this->loggers as $logger) {
  40.             $logger->startQuery($sql$params$types);
  41.         }
  42.     }
  43.     /**
  44.      * {@inheritdoc}
  45.      */
  46.     public function stopQuery()
  47.     {
  48.         foreach ($this->loggers as $logger) {
  49.             $logger->stopQuery();
  50.         }
  51.     }
  52. }