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