You are here

public function CartTokenSubscriber::onResponse in Commerce Cart API 8

Ensures the Vary header contains the cart token header name.

Parameters

\Symfony\Component\HttpKernel\Event\ResponseEvent $event: The response event.

File

src/EventSubscriber/CartTokenSubscriber.php, line 95

Class

CartTokenSubscriber
Cart token subscriber.

Namespace

Drupal\commerce_cart_api\EventSubscriber

Code

public function onResponse(ResponseEvent $event) {
  if (!$event
    ->isMasterRequest()) {
    return;
  }
  $request = $event
    ->getRequest();
  if ($request->headers
    ->has(CartTokenSession::HEADER_NAME)) {
    $response = $event
      ->getResponse();
    $response
      ->setVary(CartTokenSession::HEADER_NAME, FALSE);
  }
}