You are here

public function ConfigSubscriber::onResponse in JSON:API Image Styles 2.0.x

Same name and namespace in other branches
  1. 3.0.x src/EventSubscriber/ConfigSubscriber.php \Drupal\jsonapi_image_styles\EventSubscriber\ConfigSubscriber::onResponse()

Associates config cache tag with all JSON:API responses.

Parameters

\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event: Response event.

File

src/EventSubscriber/ConfigSubscriber.php, line 32

Class

ConfigSubscriber
Associates config cache tag with all JSON:API responses.

Namespace

Drupal\jsonapi_image_styles\EventSubscriber

Code

public function onResponse(FilterResponseEvent $event) : void {
  if ($event
    ->getRequest()
    ->getRequestFormat() !== 'api_json') {
    return;
  }
  $response = $event
    ->getResponse();
  if (!$response instanceof CacheableResponseInterface) {
    return;
  }
  $response
    ->getCacheableMetadata()
    ->addCacheTags([
    'config:jsonapi_image_styles.settings',
  ]);
}