.../src/EventSubscriber/ResourceResponseSubscriber.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/modules/rest/src/EventSubscriber/ResourceResponseSubscriber.php b/core/modules/rest/src/EventSubscriber/ResourceResponseSubscriber.php index 338b233..ef33817 100644 --- a/core/modules/rest/src/EventSubscriber/ResourceResponseSubscriber.php +++ b/core/modules/rest/src/EventSubscriber/ResourceResponseSubscriber.php @@ -102,26 +102,27 @@ public function getResponseFormat(RouteMatchInterface $route_match, Request $req $content_type_format = $request->getContentType(); // If an acceptable response format is requested, then use that. Otherwise, - // including and particularly when the client forgot to specify a response + // including and particularly when the client forgot to specify a response // format, then use heuristics to select the format that is most likely // expected. - if (in_array($requested_format, $acceptable_response_formats)) { + if (in_array($requested_format, $acceptable_response_formats, TRUE)) { return $requested_format; } + // If a request body is present, then use the format corresponding to the // request body's Content-Type for the response, if it's an acceptable // format for the request. - elseif (!empty($request->getContent()) && in_array($content_type_format, $acceptable_request_formats)) { + if (!empty($request->getContent()) && in_array($content_type_format, $acceptable_request_formats, TRUE)) { return $content_type_format; } + // Otherwise, use the first acceptable format. - elseif (!empty($acceptable_formats)) { + if (!empty($acceptable_formats)) { return $acceptable_formats[0]; } + // Sometimes, there are no acceptable formats, e.g. DELETE routes. - else { - return NULL; - } + return NULL; } /**