public function ConfigSubscriber::onResponse in JSON:API Extras 8.2
Same name and namespace in other branches
- 8.3 src/EventSubscriber/ConfigSubscriber.php \Drupal\jsonapi_extras\EventSubscriber\ConfigSubscriber::onResponse()
Associates JSON API Extras' config cache tag with all JSON API responses.
Parameters
\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event: The response event.
File
- src/
EventSubscriber/ ConfigSubscriber.php, line 78
Class
- ConfigSubscriber
- Associates config cache tag and rebuilds container + routes when necessary.
Namespace
Drupal\jsonapi_extras\EventSubscriberCode
public function onResponse(FilterResponseEvent $event) {
if ($event
->getRequest()
->getRequestFormat() !== 'api_json') {
return;
}
$response = $event
->getResponse();
if (!$response instanceof CacheableResponseInterface) {
return;
}
$response
->getCacheableMetadata()
->addCacheTags([
'config:jsonapi_extras.settings',
'config:jsonapi_resource_config_list',
]);
}