protected function renderResponseBody(Request
$request, ResourceResponse
$response, SerializerInterface
$serializer,
$format) { $data =
$response->
getResponseData();
// If there is data to send, serialize and set it as the response body.
if ($data !== NULL
) { // First normalize the data. Note that error responses do not need a
// normalization context, since there are no entities to normalize.
// @see \Drupal\jsonapi\EventSubscriber\DefaultExceptionSubscriber::isJsonApiExceptionEvent()
$context = !
$response->
isSuccessful() ?
[] :
static::
generateContext($request);
$jsonapi_doc_object =
$serializer->
normalize($data,
$format,
$context);
// Having just normalized the data, we can associate its cacheability with
// the response object.
if ($response instanceof CacheableResponseInterface
) {