diff --git a/core/lib/Drupal/Core/Http/LinkRelationManagerInterface.php b/core/lib/Drupal/Core/Http/LinkRelationManagerInterface.php index eb181a1..5ac742b 100644 --- a/core/lib/Drupal/Core/Http/LinkRelationManagerInterface.php +++ b/core/lib/Drupal/Core/Http/LinkRelationManagerInterface.php @@ -1,13 +1,8 @@ getEntityType()->getLinkTemplates() as $relation_name => $link_template) { - if ($this->linkRelationManager->getDefinition($relation_name, FALSE)) { + if ($definition = $this->linkRelationManager->getDefinition($relation_name, FALSE)) { $generator_url = $entity->toUrl($relation_name) ->setAbsolute(TRUE) ->toString(TRUE); diff --git a/core/modules/rest/src/Tests/NodeTest.php b/core/modules/rest/src/Tests/NodeTest.php index cb443ce..ae02b33 100644 --- a/core/modules/rest/src/Tests/NodeTest.php +++ b/core/modules/rest/src/Tests/NodeTest.php @@ -82,7 +82,7 @@ public function testNodes() { $this->httpRequest($node->urlInfo()->setRouteParameter('_format', $this->defaultFormat), 'GET'); $this->assertResponse(200); $this->assertHeader('Content-type', $this->defaultMimeType); - $this->assertLinkHeader($node, ['edit-form' => 'https://drupal.org/link-relations/edit-form', 'canonical' => 'canonical', 'version-history' => 'version-history']); + $this->assertLinkHeaders($node, ['canonical' => 'canonical', 'edit-form' => 'https://drupal.org/link-relations/edit-form', 'version-history' => 'version-history']); // Also check that JSON works and the routing system selects the correct // REST route. @@ -90,7 +90,7 @@ public function testNodes() { $this->httpRequest($node->urlInfo()->setRouteParameter('_format', 'json'), 'GET'); $this->assertResponse(200); $this->assertHeader('Content-type', 'application/json'); - $this->assertLinkHeader($node, ['edit-form' => 'https://drupal.org/link-relations/edit-form', 'canonical' => 'canonical', 'version-history' => 'version-history']); + $this->assertLinkHeaders($node, ['canonical' => 'canonical', 'edit-form' => 'https://drupal.org/link-relations/edit-form', 'version-history' => 'version-history']); // Check that a simple PATCH update to the node title works as expected. $this->enableNodeConfiguration('PATCH', 'update'); diff --git a/core/modules/rest/src/Tests/RESTTestBase.php b/core/modules/rest/src/Tests/RESTTestBase.php index 06ff57f..a707785 100644 --- a/core/modules/rest/src/Tests/RESTTestBase.php +++ b/core/modules/rest/src/Tests/RESTTestBase.php @@ -551,7 +551,7 @@ protected function configEntityValues($entity_type_id) { * * @return bool */ - protected function assertLinkHeader(EntityInterface $entity, array $link_relationships = ['canonical', 'edit-form']) { + protected function assertLinkHeaders(EntityInterface $entity, array $link_relationships = ['canonical', 'edit-form']) { // Add expected Link Headers. $link_headers = []; foreach ($link_relationships as $relation_name => $relationship) { diff --git a/core/modules/rest/src/Tests/ReadTest.php b/core/modules/rest/src/Tests/ReadTest.php index 4b7ae03..0830921 100644 --- a/core/modules/rest/src/Tests/ReadTest.php +++ b/core/modules/rest/src/Tests/ReadTest.php @@ -120,10 +120,10 @@ public function testRead() { $this->assertResponse(200); $data = Json::decode($response); $this->assertFalse(isset($data['field_test_text']), 'Field access protected field is not visible in the response.'); - $this->assertLinkHeader($entity, [ + $this->assertLinkHeaders($entity, [ + 'canonical' => 'canonical', 'add-form' => 'https://drupal.org/link-relations/add-form', 'edit-form' => 'https://drupal.org/link-relations/edit-form', - 'canonical' => 'canonical', ]); } }