diff --git a/core/modules/link/link.module b/core/modules/link/link.module index 46aeeba..caf8a79 100644 --- a/core/modules/link/link.module +++ b/core/modules/link/link.module @@ -5,6 +5,7 @@ * Defines simple link field types. */ +use Drupal\Core\Link; use Drupal\Core\Routing\RouteMatchInterface; /** @@ -61,5 +62,5 @@ function link_theme() { * - url: A \Drupal\Core\Url object. */ function template_preprocess_link_formatter_link_separate(&$variables) { - $variables['link'] = \Drupal::l($variables['url_title'], $variables['url']); + $variables['link'] = Link::fromTextAndUrl($variables['url_title'], $variables['url'])->toString(); } diff --git a/core/modules/link/src/Tests/LinkFieldTest.php b/core/modules/link/src/Tests/LinkFieldTest.php index e85ad53..84e90f5 100644 --- a/core/modules/link/src/Tests/LinkFieldTest.php +++ b/core/modules/link/src/Tests/LinkFieldTest.php @@ -4,6 +4,7 @@ use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Unicode; +use Drupal\Core\Link; use Drupal\Core\Url; use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; @@ -318,7 +319,7 @@ function testLinkTitle() { $this->assertText(t('entity_test @id has been created.', array('@id' => $id))); $this->renderTestEntity($id); - $expected_link = \Drupal::l($value, Url::fromUri($value)); + $expected_link = Link::fromTextAndUrl($value, Url::fromUri($value))->toString(); $this->assertRaw($expected_link); // Verify that a link with text is rendered using the link text. @@ -330,7 +331,7 @@ function testLinkTitle() { $this->assertText(t('entity_test @id has been updated.', array('@id' => $id))); $this->renderTestEntity($id); - $expected_link = \Drupal::l($title, Url::fromUri($value)); + $expected_link = Link::fromTextAndUrl($title, Url::fromUri($value))->toString(); $this->assertRaw($expected_link); } diff --git a/core/modules/link/templates/link-formatter-link-separate.html.twig b/core/modules/link/templates/link-formatter-link-separate.html.twig index 469cd9a..b238b4e 100644 --- a/core/modules/link/templates/link-formatter-link-separate.html.twig +++ b/core/modules/link/templates/link-formatter-link-separate.html.twig @@ -4,7 +4,8 @@ * Default theme implementation of a link with separate title and URL elements. * * Available variables: - * - link: The link that has already been formatted by l(). + * - link: The link that has already been formatted by + * \Drupal\Core\Link::fromTextAndUrl()->toString(). * - title: (optional) A descriptive or alternate title for the link, which may * be different than the actual link text. *