Loading core/lib/Drupal/Core/Entity/EntityBase.php +1 −1 Original line number Diff line number Diff line Loading @@ -271,7 +271,7 @@ protected function urlRouteParameters($rel) { $parameter_name = $this->getEntityType()->getBundleEntityType() ?: $this->getEntityType()->getKey('bundle'); $uri_route_parameters[$parameter_name] = $this->bundle(); } if ($rel === 'revision' && $this instanceof RevisionableInterface) { if ($this instanceof RevisionableInterface && strpos($rel, 'revision') === 0) { $uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId(); } Loading core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php +6 −4 Original line number Diff line number Diff line Loading @@ -176,11 +176,12 @@ public function testToUrlLinkTemplateRevision($is_default_revision, $link_templa $entity->method('isDefaultRevision')->willReturn($is_default_revision); $this->registerLinkTemplate($link_template); // Even though this is tested with both the 'canonical' and the 'revision' // template registered with the entity, we always ask for the 'revision' // link template, to test that it falls back to the 'canonical' link // template in case of the default revision. // template registered with the entity, we ask for the 'revision' link // template instead of 'canonical', to test that it falls back to the // 'canonical' link template in case of the default revision. $link_template = $link_template === 'canonical' ? 'revision' : $link_template; /** @var \Drupal\Core\Url $url */ $url = $entity->toUrl('revision'); $url = $entity->toUrl($link_template); $this->assertUrl($expected_route_name, $expected_route_parameters, $entity, TRUE, $url); } Loading @@ -199,6 +200,7 @@ public function providerTestToUrlLinkTemplateRevision() { // Add the revision ID to the expected route parameters. $route_parameters['test_entity_revision'] = $this->revisionId; $test_cases['non_default_revision'] = [static::NON_DEFAULT_REVISION, 'revision', 'entity.test_entity.revision', $route_parameters]; $test_cases['revision-delete'] = [static::NON_DEFAULT_REVISION, 'revision-delete-form', 'entity.test_entity.revision_delete_form', $route_parameters]; return $test_cases; } Loading Loading
core/lib/Drupal/Core/Entity/EntityBase.php +1 −1 Original line number Diff line number Diff line Loading @@ -271,7 +271,7 @@ protected function urlRouteParameters($rel) { $parameter_name = $this->getEntityType()->getBundleEntityType() ?: $this->getEntityType()->getKey('bundle'); $uri_route_parameters[$parameter_name] = $this->bundle(); } if ($rel === 'revision' && $this instanceof RevisionableInterface) { if ($this instanceof RevisionableInterface && strpos($rel, 'revision') === 0) { $uri_route_parameters[$this->getEntityTypeId() . '_revision'] = $this->getRevisionId(); } Loading
core/tests/Drupal/Tests/Core/Entity/EntityUrlTest.php +6 −4 Original line number Diff line number Diff line Loading @@ -176,11 +176,12 @@ public function testToUrlLinkTemplateRevision($is_default_revision, $link_templa $entity->method('isDefaultRevision')->willReturn($is_default_revision); $this->registerLinkTemplate($link_template); // Even though this is tested with both the 'canonical' and the 'revision' // template registered with the entity, we always ask for the 'revision' // link template, to test that it falls back to the 'canonical' link // template in case of the default revision. // template registered with the entity, we ask for the 'revision' link // template instead of 'canonical', to test that it falls back to the // 'canonical' link template in case of the default revision. $link_template = $link_template === 'canonical' ? 'revision' : $link_template; /** @var \Drupal\Core\Url $url */ $url = $entity->toUrl('revision'); $url = $entity->toUrl($link_template); $this->assertUrl($expected_route_name, $expected_route_parameters, $entity, TRUE, $url); } Loading @@ -199,6 +200,7 @@ public function providerTestToUrlLinkTemplateRevision() { // Add the revision ID to the expected route parameters. $route_parameters['test_entity_revision'] = $this->revisionId; $test_cases['non_default_revision'] = [static::NON_DEFAULT_REVISION, 'revision', 'entity.test_entity.revision', $route_parameters]; $test_cases['revision-delete'] = [static::NON_DEFAULT_REVISION, 'revision-delete-form', 'entity.test_entity.revision_delete_form', $route_parameters]; return $test_cases; } Loading