core/modules/rest/src/RequestHandler.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/modules/rest/src/RequestHandler.php b/core/modules/rest/src/RequestHandler.php index 4dcdc9f..54b0ded 100644 --- a/core/modules/rest/src/RequestHandler.php +++ b/core/modules/rest/src/RequestHandler.php @@ -79,7 +79,7 @@ public function handle(RouteMatchInterface $route_match, Request $request) { // format. If the serializer cannot handle it an exception will be thrown // that bubbles up to the client. $request_method = $request->getMethod(); - if (!$resource_config->hasSupportedFormats($request_method) || $resource_config->supportsFormat($request_method, $format)) { + if (in_array($format, $resource_config->getSupportedFormats($request_method))) { $definition = $resource->getPluginDefinition(); $class = $definition['serialization_class']; try { @@ -178,6 +178,9 @@ protected function renderResponse(Request $request, ResourceResponseInterface $r if (!$context->isEmpty()) { $response->addCacheableDependency($context->pop()); } + + // Add rest config's cache tags. + $response->addCacheableDependency($resource_config); } else { $output = $serializer->serialize($data, $format); @@ -185,9 +188,6 @@ protected function renderResponse(Request $request, ResourceResponseInterface $r $response->setContent($output); $response->headers->set('Content-Type', $request->getMimeType($format)); - // Add rest config's cache tags. - $response->addCacheableDependency($resource_config); - return $response; }