custom/plugins/FroshDevelopmentHelper/src/Subscriber/DisableStorefrontErrorHandling.php line 28

Open in your IDE?
  1. <?php
  2. namespace Frosh\DevelopmentHelper\Subscriber;
  3. use Shopware\Core\PlatformRequest;
  4. use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use Symfony\Component\HttpKernel\Event\ExceptionEvent;
  7. use Symfony\Component\HttpKernel\KernelEvents;
  8. class DisableStorefrontErrorHandling implements EventSubscriberInterface
  9. {
  10.     /** @var ContainerBagInterface */
  11.     private $containerBag;
  12.     public function __construct(ContainerBagInterface $containerBag)
  13.     {
  14.         $this->containerBag $containerBag;
  15.     }
  16.     public static function getSubscribedEvents()
  17.     {
  18.         return [
  19.             KernelEvents::EXCEPTION => ['disableFrontendErrorHandling', -95]
  20.         ];
  21.     }
  22.     public function disableFrontendErrorHandling(ExceptionEvent $event)
  23.     {
  24.         //if we are in dev mode, we will see exceptions
  25.         if ($this->containerBag->all()['kernel.debug']) {
  26.             return;
  27.         }
  28.         if ($event->getRequest()->attributes->has(PlatformRequest::ATTRIBUTE_SALES_CHANNEL_CONTEXT_OBJECT)) {
  29.             $event->stopPropagation();
  30.         }
  31.     }
  32. }