public function onResponse(ResponseEvent
$event) { $response =
$event->
getResponse();
if (!
$response instanceof ResourceResponseInterface
) { return;
} $request =
$event->
getRequest();
$format =
$this->
getResponseFormat($this->routeMatch,
$request);
$this->
renderResponseBody($request,
$response,
$this->serializer,
$format);
$event->
setResponse($this->
flattenResponse($response));
} /**
* Determines the format to respond in.
*
* Respects the requested format if one is specified. However, it is common to
* forget to specify a response format in case of a POST or PATCH. Rather than
* simply throwing an error, we apply the robustness principle: when POSTing
* or PATCHing using a certain format, you probably expect a response in that
* same format.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The current route match.
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request.
*
* @return string
* The response format.
*/