public function RouteAccessResponseSubscriber::onRespond in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/EventSubscriber/RouteAccessResponseSubscriber.php \Drupal\Core\EventSubscriber\RouteAccessResponseSubscriber::onRespond()
Bubbles the route's access result' cacheability metadata.
Parameters
\Symfony\Component\HttpKernel\Event\ResponseEvent $event: The event to process.
File
- core/
lib/ Drupal/ Core/ EventSubscriber/ RouteAccessResponseSubscriber.php, line 32
Class
- RouteAccessResponseSubscriber
- Response subscriber to bubble the route's access result's cacheability.
Namespace
Drupal\Core\EventSubscriberCode
public function onRespond(ResponseEvent $event) {
if (!$event
->isMainRequest()) {
return;
}
$response = $event
->getResponse();
if (!$response instanceof CacheableResponseInterface) {
return;
}
$request = $event
->getRequest();
$access_result = $request->attributes
->get(AccessAwareRouterInterface::ACCESS_RESULT);
$response
->addCacheableDependency($access_result);
}