Chris@0: isMasterRequest()) { Chris@0: return; Chris@0: } Chris@0: Chris@0: $response = $event->getResponse(); Chris@0: if (!$response instanceof CacheableResponseInterface) { Chris@0: return; Chris@0: } Chris@0: Chris@0: $request = $event->getRequest(); Chris@0: $access_result = $request->attributes->get(AccessAwareRouterInterface::ACCESS_RESULT); Chris@0: $response->addCacheableDependency($access_result); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public static function getSubscribedEvents() { Chris@0: // Priority 10, so that it runs before FinishResponseSubscriber, which will Chris@0: // expose the cacheability metadata in the form of headers. Chris@0: $events[KernelEvents::RESPONSE][] = ['onRespond', 10]; Chris@0: return $events; Chris@0: } Chris@0: Chris@0: }