diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php b/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php index 6fd2170..fc69554 100644 --- a/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php +++ b/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php @@ -79,13 +79,9 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio $request = $container->get('request'); $request_content_type = $negotiation->getContentType($request); - // Only set the requested content type if it's not html. - if ($request_content_type === 'html') { - if (\Drupal::moduleHandler()->moduleExists('hal')) { - $this->setContentType('hal_json'); - } - } - else { + // Only set the requested content type if it's not 'html'. The default + // 'json' content will be used in this case. + if ($request_content_type !== 'html') { $this->setContentType($request_content_type); } diff --git a/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php b/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php index 4824307..8a62fe1 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php @@ -120,22 +120,16 @@ public function testSerializerResponses() { $actual_json = $this->drupalGet('test/serialize/entity', array(), array('Accept: application/json')); $this->assertResponse(200); - $this->assertIdentical($actual_json, $expected, 'The expected JSON output was found.'); $expected = $serializer->serialize($entities, 'hal_json'); $actual_json = $this->drupalGet('test/serialize/entity', array(), array('Accept: application/hal+json')); $this->assertIdentical($actual_json, $expected, 'The expected HAL output was found.'); - // Test that by default the output will be JSON if hal is enabled. - $expected = $serializer->serialize($entities, 'hal_json'); - $actual = $this->drupalGet('test/serialize/entity'); - $this->assertIdentical($actual, $expected, 'If hal module is enabled by default hal_json output is returned.'); - - module_disable(array('hal')); + // Test that the default output will be JSON if html is requested. $expected = $serializer->serialize($entities, 'json'); $actual = $this->drupalGet('test/serialize/entity'); - $this->assertIdentical($actual, $expected, 'By default json output is returned.'); + $this->assertIdentical($actual, $expected, 'If hal module is enabled by default hal_json output is returned.'); } /** @@ -247,9 +241,9 @@ public function testPreview() { $entities[] = $row->_entity; } - $expected = check_plain($serializer->serialize($entities, 'hal_json')); + $expected = check_plain($serializer->serialize($entities, 'json')); - $view->display_handler->setContentType('hal_json'); + $view->display_handler->setContentType('json'); $view->live_preview = TRUE; $build = $view->preview();