You are here

public function ResourceResponseValidator::onResponse in JSON:API 8.2

Same name and namespace in other branches
  1. 8 src/EventSubscriber/ResourceResponseValidator.php \Drupal\jsonapi\EventSubscriber\ResourceResponseValidator::onResponse()

Validates JSON:API responses.

Parameters

\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event: The event to process.

File

src/EventSubscriber/ResourceResponseValidator.php, line 135

Class

ResourceResponseValidator
Response subscriber that validates a JSON:API response.

Namespace

Drupal\jsonapi\EventSubscriber

Code

public function onResponse(FilterResponseEvent $event) {
  $response = $event
    ->getResponse();
  if (strpos($response->headers
    ->get('Content-Type'), 'application/vnd.api+json') === FALSE) {
    return;
  }
  $this
    ->doValidateResponse($response, $event
    ->getRequest());
}