vendor/payum/payum-bundle/EventListener/ReplyToHttpResponseListener.php line 17

Open in your IDE?
  1. <?php
  2. namespace Payum\Bundle\PayumBundle\EventListener;
  3. use Payum\Core\Bridge\Symfony\ReplyToSymfonyResponseConverter;
  4. use Payum\Core\Reply\ReplyInterface;
  5. use Symfony\Component\HttpKernel\Event\ExceptionEvent;
  6. class ReplyToHttpResponseListener
  7. {
  8.     private ReplyToSymfonyResponseConverter $replyToSymfonyResponseConverter;
  9.     public function __construct(ReplyToSymfonyResponseConverter $replyToSymfonyResponseConverter)
  10.     {
  11.         $this->replyToSymfonyResponseConverter $replyToSymfonyResponseConverter;
  12.     }
  13.     public function onKernelException(ExceptionEvent $event): void
  14.     {
  15.         if (false === $event->getThrowable() instanceof ReplyInterface) {
  16.             return;
  17.         }
  18.         /** @var $throwable ReplyInterface */
  19.         $throwable $event->getThrowable();
  20.         $response $this->replyToSymfonyResponseConverter->convert($throwable);
  21.         $event->allowCustomResponseCode();
  22.         $event->setResponse($response);
  23.     }
  24. }