vendor/shopware/core/Framework/DataAbstractionLayer/Dbal/ExceptionHandlerRegistry.php line 23

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Framework\DataAbstractionLayer\Dbal;
  3. use Shopware\Core\Framework\DataAbstractionLayer\Write\Command\WriteCommand;
  4. use Shopware\Core\Framework\Feature;
  5. /**
  6.  * @deprecated tag:v6.5.0 - reason:becomes-internal - Will be internal
  7.  */
  8. class ExceptionHandlerRegistry
  9. {
  10.     /**
  11.      * @var array
  12.      */
  13.     protected $exceptionHandlers = [];
  14.     /**
  15.      * @internal
  16.      */
  17.     public function __construct(iterable $exceptionHandlers)
  18.     {
  19.         foreach ($exceptionHandlers as $exceptionHandler) {
  20.             $this->add($exceptionHandler);
  21.         }
  22.     }
  23.     public function add(ExceptionHandlerInterface $exceptionHandler): void
  24.     {
  25.         $this->exceptionHandlers[$exceptionHandler->getPriority()][] = $exceptionHandler;
  26.     }
  27.     /**
  28.      * @internal (flag:FEATURE_NEXT_16640) - second parameter WriteCommand $command will be removed
  29.      */
  30.     public function matchException(\Exception $e, ?WriteCommand $command null): ?\Exception
  31.     {
  32.         foreach ($this->getExceptionHandlers() as $priorityExceptionHandlers) {
  33.             foreach ($priorityExceptionHandlers as $exceptionHandler) {
  34.                 if (!Feature::isActive('FEATURE_NEXT_16640')) {
  35.                     $innerException $exceptionHandler->matchException($e$command);
  36.                 } else {
  37.                     $innerException $exceptionHandler->matchException($e);
  38.                 }
  39.                 if ($innerException instanceof \Exception) {
  40.                     return $innerException;
  41.                 }
  42.             }
  43.         }
  44.         return null;
  45.     }
  46.     public function getExceptionHandlers(): array
  47.     {
  48.         return $this->exceptionHandlers;
  49.     }
  50. }