vendor/ibexa/http-cache/src/lib/EventSubscriber/UserContextSiteAccessMatchSubscriber.php line 41

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\HttpCache\EventSubscriber;
  8. use Ibexa\Core\MVC\Symfony\EventListener\SiteAccessMatchListener;
  9. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  10. use Symfony\Component\HttpFoundation\RequestMatcherInterface;
  11. use Symfony\Component\HttpKernel\Event\RequestEvent;
  12. use Symfony\Component\HttpKernel\KernelEvents;
  13. class UserContextSiteAccessMatchSubscriber implements EventSubscriberInterface
  14. {
  15.     /** @var \Ibexa\Core\MVC\Symfony\EventListener\SiteAccessMatchListener */
  16.     protected $innerSubscriber;
  17.     /** @var \Symfony\Component\HttpFoundation\RequestMatcherInterface */
  18.     private $userContextRequestMatcher;
  19.     public function __construct(
  20.         SiteAccessMatchListener $innerSubscriber,
  21.         RequestMatcherInterface $userContextRequestMatcher
  22.     ) {
  23.         $this->innerSubscriber $innerSubscriber;
  24.         $this->userContextRequestMatcher $userContextRequestMatcher;
  25.     }
  26.     public static function getSubscribedEvents()
  27.     {
  28.         return [
  29.             // Should take place just after FragmentListener (priority 48) in order to get rebuilt request attributes in case of subrequest
  30.             KernelEvents::REQUEST => ['checkIfRequestForUserContextHash'45],
  31.         ];
  32.     }
  33.     public function checkIfRequestForUserContextHash(RequestEvent $event)
  34.     {
  35.         $request $event->getRequest();
  36.         // Don't try to match when it's request for user hash . SiteAccess is irrelevant in this case.
  37.         if ($this->userContextRequestMatcher->matches($request) && !$request->attributes->has('_ez_original_request')) {
  38.             return;
  39.         }
  40.         $this->innerSubscriber->onKernelRequest($event);
  41.     }
  42. }
  43. class_alias(UserContextSiteAccessMatchSubscriber::class, 'EzSystems\PlatformHttpCacheBundle\EventSubscriber\UserContextSiteAccessMatchSubscriber');