diff --git a/core/core.services.yml b/core/core.services.yml index 6094635..8eccfa8 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -858,7 +858,7 @@ services: accept_negotiation_406: class: Drupal\Core\EventSubscriber\AcceptNegotiation406 tags: - - { name: event_subscriber, priority: -10 } + - { name: event_subscriber} main_content_renderer.html: class: Drupal\Core\Render\MainContent\HtmlRenderer arguments: ['@title_resolver', '@plugin.manager.display_variant', '@event_dispatcher', '@element_info', '@module_handler', '@renderer', '@render_cache', '@cache_contexts_manager'] diff --git a/core/lib/Drupal/Core/EventSubscriber/AcceptNegotiation406.php b/core/lib/Drupal/Core/EventSubscriber/AcceptNegotiation406.php index 4bfc942..72683e1 100644 --- a/core/lib/Drupal/Core/EventSubscriber/AcceptNegotiation406.php +++ b/core/lib/Drupal/Core/EventSubscriber/AcceptNegotiation406.php @@ -26,7 +26,7 @@ class AcceptNegotiation406 implements EventSubscriberInterface { * @param \Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent $event * The event to process. */ - function onViewDetect406(GetResponseForControllerResultEvent $event) { + public function onViewDetect406(GetResponseForControllerResultEvent $event) { $request = $event->getRequest(); $result = $event->getControllerResult(); diff --git a/core/misc/ajax.js b/core/misc/ajax.js index b6864e7..c1dd726 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -296,7 +296,7 @@ }; /** - * Url query attribute to indicate the wrapper used to render a request. + * URL query attribute to indicate the wrapper used to render a request. * * This controls wrapping the HTML content for example in a modal dialog. */ diff --git a/core/modules/hal/hal.services.yml b/core/modules/hal/hal.services.yml index 7e40df0..e817fbf 100644 --- a/core/modules/hal/hal.services.yml +++ b/core/modules/hal/hal.services.yml @@ -26,3 +26,7 @@ services: class: Drupal\hal\Encoder\JsonEncoder tags: - { name: encoder, priority: 10, format: hal_json } + exception.default_json: + class: Drupal\hal\EventSubscriber\ExceptionHalJsonSubscriber + tags: + - { name: event_subscriber } diff --git a/core/modules/hal/src/EventSubscriber/ExceptionHalJsonSubscriber.php b/core/modules/hal/src/EventSubscriber/ExceptionHalJsonSubscriber.php new file mode 100644 index 0000000..3bf3544 --- /dev/null +++ b/core/modules/hal/src/EventSubscriber/ExceptionHalJsonSubscriber.php @@ -0,0 +1,23 @@ +httpRequest($entity_type . '/9999', 'GET', NULL, $this->defaultMimeType); $this->assertResponse(404); $path = $entity_type == 'node' ? '/node/{node}' : '/entity_test/{entity_test}'; - $expected_message = Json::encode(['error' => 'A fatal error occurred: The "' . $entity_type . '" parameter was not converted for the path "' . $path . '" (route name: "rest.entity.' . $entity_type . '.GET.hal_json")']); + $expected_message = Json::encode(['message' => 'The "' . $entity_type . '" parameter was not converted for the path "' . $path . '" (route name: "rest.entity.' . $entity_type . '.GET.hal_json")']); $this->assertIdentical($expected_message, $response, 'Response message is correct.'); // Make sure that field level access works and that the according field is @@ -81,7 +81,7 @@ public function testRead() { $this->drupalLogout(); $response = $this->httpRequest($entity->urlInfo(), 'GET', NULL, $this->defaultMimeType); $this->assertResponse(403); - $this->assertIdentical('{}', $response); + $this->assertIdentical('{"message":""}', $response); } // Try to read a resource which is not REST API enabled. $account = $this->drupalCreateUser(); @@ -93,7 +93,7 @@ public function testRead() { // used, but it can't render into application/hal+json, so it returns a 406. $this->assertResponse('406', 'HTTP response code is 406 when the resource does not define formats, because it falls back to the canonical, non-REST route.'); $this->assertEqual($response, Json::encode([ - 'error' => 'A fatal error occurred: Not acceptable', + 'message' => 'Not acceptable', ])); }