vendor/ibexa/page-builder/src/lib/Event/Subscriber/ExceptionSubscriber.php line 49

Open in your IDE?
  1. <?php
  2. /**
  3.  * @copyright Copyright (C) Ibexa AS. All rights reserved.
  4.  * @license For full copyright and license information view LICENSE file distributed with this source code.
  5.  */
  6. declare(strict_types=1);
  7. namespace Ibexa\PageBuilder\Event\Subscriber;
  8. use Ibexa\Core\Helper\ContentPreviewHelper;
  9. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  10. use Symfony\Component\HttpKernel\Event\ExceptionEvent;
  11. use Symfony\Component\HttpKernel\KernelEvents;
  12. /**
  13.  * Kernel Exception Event Subscriber which restores proper SA context when needed.
  14.  */
  15. class ExceptionSubscriber implements EventSubscriberInterface
  16. {
  17.     /**
  18.      * @var \Ibexa\Core\Helper\ContentPreviewHelper
  19.      */
  20.     private $previewHelper;
  21.     /**
  22.      * @param \Ibexa\Core\Helper\ContentPreviewHelper $previewHelper
  23.      */
  24.     public function __construct(ContentPreviewHelper $previewHelper)
  25.     {
  26.         $this->previewHelper $previewHelper;
  27.     }
  28.     /**
  29.      * @return array
  30.      */
  31.     public static function getSubscribedEvents()
  32.     {
  33.         return [
  34.             KernelEvents::EXCEPTION => [
  35.                 ['onKernelException'10],
  36.             ],
  37.         ];
  38.     }
  39.     /**
  40.      * @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
  41.      */
  42.     public function onKernelException(ExceptionEvent $event)
  43.     {
  44.         $request $event->getRequest();
  45.         $originalSiteAccess $request->get('originalSiteAccess');
  46.         if (empty($originalSiteAccess)) {
  47.             return;
  48.         }
  49.         // restore original config scope (SiteAccess) to handle Exception
  50.         $this->previewHelper->changeConfigScope($originalSiteAccess);
  51.     }
  52. }
  53. class_alias(ExceptionSubscriber::class, 'EzSystems\EzPlatformPageBuilder\Event\Subscriber\ExceptionSubscriber');