vendor/shopware/storefront/Framework/Routing/ResponseHeaderListener.php line 17

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Storefront\Framework\Routing;
  3. use Shopware\Core\Framework\Routing\Annotation\RouteScope;
  4. use Shopware\Core\PlatformRequest;
  5. use Symfony\Component\HttpKernel\Event\ResponseEvent;
  6. class ResponseHeaderListener
  7. {
  8.     private const HEADERS = [
  9.         PlatformRequest::HEADER_VERSION_ID,
  10.         PlatformRequest::HEADER_LANGUAGE_ID,
  11.         PlatformRequest::HEADER_CONTEXT_TOKEN,
  12.     ];
  13.     public function __invoke(ResponseEvent $event): void
  14.     {
  15.         /** @var RouteScope|null $routeScope */
  16.         $routeScope $event->getRequest()->attributes->get('_routeScope');
  17.         if ($routeScope === null || !$routeScope->hasScope('storefront')) {
  18.             return;
  19.         }
  20.         foreach (self::HEADERS as $headerKey) {
  21.             $event->getResponse()->headers->remove($headerKey);
  22.         }
  23.     }
  24. }