vendor/ezsystems/ezplatform-http-cache/src/EventSubscriber/HiddenLocationExceptionSubscriber.php line 39

Open in your IDE?
  1. <?php
  2. /**
  3.  * @copyright Copyright (C) eZ Systems AS. All rights reserved.
  4.  * @license For full copyright and license information view LICENSE file distributed with this source code.
  5.  */
  6. namespace EzSystems\PlatformHttpCacheBundle\EventSubscriber;
  7. use eZ\Publish\Core\MVC\Exception\HiddenLocationException;
  8. use EzSystems\PlatformHttpCacheBundle\ResponseTagger\Value\ContentInfoTagger;
  9. use EzSystems\PlatformHttpCacheBundle\ResponseTagger\Value\LocationTagger;
  10. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  11. use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
  12. use Symfony\Component\HttpKernel\KernelEvents;
  13. class HiddenLocationExceptionSubscriber implements EventSubscriberInterface
  14. {
  15.     /**
  16.      * @var \EzSystems\PlatformHttpCacheBundle\ResponseTagger\Value\LocationTagger;
  17.      */
  18.     private $locationTagger;
  19.     /**
  20.      * @var \EzSystems\PlatformHttpCacheBundle\ResponseTagger\Value\ContentInfoTagger
  21.      */
  22.     private $contentInfoTagger;
  23.     public function __construct(LocationTagger $locationTaggerContentInfoTagger $contentInfoTagger)
  24.     {
  25.         $this->locationTagger $locationTagger;
  26.         $this->contentInfoTagger $contentInfoTagger;
  27.     }
  28.     public static function getSubscribedEvents()
  29.     {
  30.         return [KernelEvents::EXCEPTION => ['tagHiddenLocationExceptionResponse'10]];
  31.     }
  32.     public function tagHiddenLocationExceptionResponse(GetResponseForExceptionEvent $event)
  33.     {
  34.         if (!$event->getException() instanceof HiddenLocationException) {
  35.             return;
  36.         }
  37.         /** @var \eZ\Publish\API\Repository\Values\Content\Location $location */
  38.         $location $event->getException()->getLocation();
  39.         $this->locationTagger->tag($location);
  40.         $this->contentInfoTagger->tag($location->getContentInfo());
  41.     }
  42. }