You are here

public function FinishResponseSubscriber::onAllResponds in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php \Drupal\Core\EventSubscriber\FinishResponseSubscriber::onAllResponds()

Sets extra headers on any responses, also subrequest ones.

Parameters

\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event: The event to process.

File

core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php, line 97

Class

FinishResponseSubscriber
Response subscriber to handle finished responses.

Namespace

Drupal\Core\EventSubscriber

Code

public function onAllResponds(FilterResponseEvent $event) {
  $response = $event
    ->getResponse();

  // Always add the 'http_response' cache tag to be able to invalidate every
  // response, for example after rebuilding routes.
  if ($response instanceof CacheableResponseInterface) {
    $response
      ->getCacheableMetadata()
      ->addCacheTags([
      'http_response',
    ]);
  }
}