public function ClientErrorResponseSubscriber::onRespond in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/EventSubscriber/ClientErrorResponseSubscriber.php \Drupal\Core\EventSubscriber\ClientErrorResponseSubscriber::onRespond()
Sets the '4xx-response' cache tag on 4xx responses.
Parameters
\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event: The event to process.
File
- core/
lib/ Drupal/ Core/ EventSubscriber/ ClientErrorResponseSubscriber.php, line 27 - Contains \Drupal\Core\EventSubscriber\ClientErrorResponseSubscriber.
Class
- ClientErrorResponseSubscriber
- Response subscriber to set the '4xx-response' cache tag on 4xx responses.
Namespace
Drupal\Core\EventSubscriberCode
public function onRespond(FilterResponseEvent $event) {
if (!$event
->isMasterRequest()) {
return;
}
$response = $event
->getResponse();
if (!$response instanceof CacheableResponseInterface) {
return;
}
if ($response
->isClientError()) {
$http_4xx_response_cacheability = new CacheableMetadata();
$http_4xx_response_cacheability
->setCacheTags([
'4xx-response',
]);
$response
->addCacheableDependency($http_4xx_response_cacheability);
}
}