.../src/Functional/FileUploadResourceTestBase.php | 22 ---------------------- .../EventSubscriber/ResourceResponseSubscriber.php | 6 +++--- core/modules/rest/src/Routing/ResourceRoutes.php | 10 +--------- 3 files changed, 4 insertions(+), 34 deletions(-) diff --git a/core/modules/file/tests/src/Functional/FileUploadResourceTestBase.php b/core/modules/file/tests/src/Functional/FileUploadResourceTestBase.php index 15cfa09..29af273 100644 --- a/core/modules/file/tests/src/Functional/FileUploadResourceTestBase.php +++ b/core/modules/file/tests/src/Functional/FileUploadResourceTestBase.php @@ -124,13 +124,6 @@ protected function setUpAuthorization($method) { /** * {@inheritdoc} */ - protected function assertResponseWhenMissingAuthentication(ResponseInterface $response) { - // TODO: Implement assertResponseWhenMissingAuthentication() method. - } - - /** - * {@inheritdoc} - */ protected function assertNormalizationEdgeCases($method, Url $url, array $request_options) { // TODO: Implement assertNormalizationEdgeCases() method. } @@ -138,26 +131,11 @@ protected function assertNormalizationEdgeCases($method, Url $url, array $reques /** * {@inheritdoc} */ - protected function assertAuthenticationEdgeCases($method, Url $url, array $request_options) { - // TODO: Implement assertAuthenticationEdgeCases() method. - } - - /** - * {@inheritdoc} - */ protected function getExpectedUnauthorizedAccessMessage($method) { // TODO: Implement getExpectedUnauthorizedAccessMessage() method. } /** - * {@inheritdoc} - */ - protected function getExpectedBcUnauthorizedAccessMessage($method) { - // TODO: Implement getExpectedBcUnauthorizedAccessMessage() method. - } - - - /** * Tests using the file upload POST route. */ public function testPostFileUpload() { diff --git a/core/modules/rest/src/EventSubscriber/ResourceResponseSubscriber.php b/core/modules/rest/src/EventSubscriber/ResourceResponseSubscriber.php index 58a863e..8f90819 100644 --- a/core/modules/rest/src/EventSubscriber/ResourceResponseSubscriber.php +++ b/core/modules/rest/src/EventSubscriber/ResourceResponseSubscriber.php @@ -96,7 +96,7 @@ public function getResponseFormat(RouteMatchInterface $route_match, Request $req $route = $route_match->getRouteObject(); $acceptable_request_formats = $route->hasRequirement('_format') ? explode('|', $route->getRequirement('_format')) : []; $acceptable_content_type_formats = $route->hasRequirement('_content_type_format') ? explode('|', $route->getRequirement('_content_type_format')) : []; - $fallback_acceptable_formats = $request->isMethodCacheable() ? $acceptable_request_formats : $acceptable_content_type_formats; + $acceptable_formats = $request->isMethodCacheable() ? $acceptable_request_formats : $acceptable_content_type_formats; $requested_format = $request->getRequestFormat(); $content_type_format = $request->getContentType(); @@ -114,8 +114,8 @@ public function getResponseFormat(RouteMatchInterface $route_match, Request $req return $content_type_format; } // Otherwise, use the first acceptable format. - elseif (!empty($fallback_acceptable_formats)) { - return $fallback_acceptable_formats[0]; + elseif (!empty($acceptable_formats)) { + return $acceptable_formats[0]; } // Sometimes, there are no acceptable formats, e.g. DELETE routes. else { diff --git a/core/modules/rest/src/Routing/ResourceRoutes.php b/core/modules/rest/src/Routing/ResourceRoutes.php index 33c21de..c5e1fa0 100644 --- a/core/modules/rest/src/Routing/ResourceRoutes.php +++ b/core/modules/rest/src/Routing/ResourceRoutes.php @@ -109,18 +109,10 @@ protected function getRoutesForResourceConfig(RestResourceConfigInterface $rest_ } // The configuration has been validated, so we update the route to: - // - set the allowed response body content types/formats for methods - // that may send response bodies // - set the allowed request body content types/formats for methods that // allow request bodies to be sent // - set the allowed authentication providers - // @todo Remove this in Drupal 9. @RestResource plugins should be - // given the RESTResourceConfig entity, and should generate the - // appropriate routes in ::routes() based on that. But doing so - // would be a BC break. This is the next best thing we can do. - if (in_array($method, ['GET', 'HEAD', 'POST', 'PUT', 'PATCH'], TRUE)) { - $route->addRequirements(['_format' => implode('|', $rest_resource_config->getFormats($method))]); - } + // @todo clean this up further in https://www.drupal.org/node/2858482 if (in_array($method, ['POST', 'PATCH', 'PUT'], TRUE) && !$route->hasRequirement('_content_type_format')) { $route->addRequirements(['_content_type_format' => implode('|', $rest_resource_config->getFormats($method))]); }