function RouteAccessResponseSubscriber::onRespond
Same name in other branches
- 9 core/lib/Drupal/Core/EventSubscriber/RouteAccessResponseSubscriber.php \Drupal\Core\EventSubscriber\RouteAccessResponseSubscriber::onRespond()
- 8.9.x core/lib/Drupal/Core/EventSubscriber/RouteAccessResponseSubscriber.php \Drupal\Core\EventSubscriber\RouteAccessResponseSubscriber::onRespond()
- 11.x 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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.