Unverified Commit ae248f2e authored by alexpott's avatar alexpott

Issue #3047801 by Eduardo Morales, mikelutz, pguillard, nlisgo,...

Issue #3047801 by Eduardo Morales, mikelutz, pguillard, nlisgo, sathish.redcrackle, Berdir: Replace all calls to the deprecated Drupal::l() function in Core
parent 7325b708
......@@ -606,17 +606,15 @@ public static function linkGenerator() {
* A GeneratedLink object containing a link to the given route and
* parameters and bubbleable metadata.
*
* @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use
* \Drupal\Core\Link::fromTextAndUrl() instead.
*
* @see https://www.drupal.org/node/2614344
* @see \Drupal\Core\Utility\LinkGeneratorInterface::generate()
* @see \Drupal\Core\Url
*
* @deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0.
* Use \Drupal\Core\Link instead.
* Example:
* @code
* $link = Link::fromTextAndUrl($text, $url);
* @endcode
*/
public static function l($text, Url $url) {
@trigger_error('\Drupal::l() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Link::fromTextAndUrl() instead. See https://www.drupal.org/node/2614344', E_USER_DEPRECATED);
return static::getContainer()->get('link_generator')->generate($text, $url);
}
......
......@@ -7,6 +7,7 @@
use Drupal\Core\Database\Database;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\Core\Utility\UpdateException;
......@@ -952,7 +953,7 @@ function hook_requirements($phase) {
// Test PHP version
$requirements['php'] = [
'title' => t('PHP'),
'value' => ($phase == 'runtime') ? \Drupal::l(phpversion(), new Url('system.php')) : phpversion(),
'value' => ($phase == 'runtime') ? Link::fromTextAndUrl(phpversion(), Url::fromRoute('system.php'))->toString() : phpversion(),
];
if (version_compare(phpversion(), DRUPAL_MINIMUM_PHP) < 0) {
$requirements['php']['description'] = t('Your PHP installation is too old. Drupal requires at least PHP %version.', ['%version' => DRUPAL_MINIMUM_PHP]);
......
......@@ -2,6 +2,7 @@
namespace Drupal\Core\Render\Element;
use Drupal\Core\Link as BaseLink;
use Drupal\Core\Url as BaseUrl;
use Drupal\Component\Utility\NestedArray;
......@@ -78,7 +79,7 @@ public static function preRenderCompactLink($element) {
}
$options = NestedArray::mergeDeep($element['#url']->getOptions(), $element['#options']);
$element['#markup'] = \Drupal::l($element['#title'], $element['#url']->setOptions($options));
$element['#markup'] = BaseLink::fromTextAndUrl($element['#title'], $element['#url']->setOptions($options))->toString();
return $element;
}
......
......@@ -4,6 +4,7 @@
use Drupal\Component\Utility\Xss;
use Drupal\Core\Render\RenderContext;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Views;
......@@ -111,7 +112,7 @@ public function testAggregatorItemView() {
// Ensure that the rendering of the linked title works as expected.
foreach ($view->result as $row) {
$iid = $view->field['iid']->getValue($row);
$expected_link = \Drupal::l($items[$iid]->getTitle(), Url::fromUri($items[$iid]->getLink(), ['absolute' => TRUE]));
$expected_link = Link::fromTextAndUrl($items[$iid]->getTitle(), Url::fromUri($items[$iid]->getLink(), ['absolute' => TRUE]))->toString();
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($view, $row) {
return $view->field['title']->advancedRender($row);
});
......
......@@ -7,6 +7,7 @@
use Drupal\Component\Utility\Html;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\language\ConfigurableLanguageInterface;
use Drupal\system\Entity\Menu;
......@@ -43,7 +44,7 @@ function block_help($route_name, RouteMatchInterface $route_match) {
$demo_theme = $route_match->getParameter('theme') ?: \Drupal::config('system.theme')->get('default');
$themes = \Drupal::service('theme_handler')->listInfo();
$output = '<p>' . t('Block placement is specific to each theme on your site. Changes will not be saved until you click <em>Save blocks</em> at the bottom of the page.') . '</p>';
$output .= '<p>' . \Drupal::l(t('Demonstrate block regions (@theme)', ['@theme' => $themes[$demo_theme]->info['name']]), new Url('block.admin_demo', ['theme' => $demo_theme])) . '</p>';
$output .= '<p>' . Link::fromTextAndUrl(t('Demonstrate block regions (@theme)', ['@theme' => $themes[$demo_theme]->info['name']]), Url::fromRoute('block.admin_demo', ['theme' => $demo_theme]))->toString() . '</p>';
return $output;
}
}
......
......@@ -5,6 +5,7 @@
* Provides page callbacks for custom blocks.
*/
use Drupal\Core\Link;
use Drupal\Core\Url;
/**
......@@ -23,7 +24,7 @@ function template_preprocess_block_content_add_list(&$variables) {
$query = \Drupal::request()->query->all();
foreach ($variables['content'] as $type) {
$variables['types'][$type->id()] = [
'link' => \Drupal::l($type->label(), new Url('block_content.add_form', ['block_content_type' => $type->id()], ['query' => $query])),
'link' => Link::fromTextAndUrl($type->label(), Url::fromRoute('block_content.add_form', ['block_content_type' => $type->id()], ['query' => $query]))->toString(),
'description' => [
'#markup' => $type->getDescription(),
],
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\book\Functional;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Entity\EntityInterface;
......@@ -106,14 +107,14 @@ public function checkBookNode(EntityInterface $node, $nodes, $previous, $up, $ne
$url = $previous->toUrl();
$url->setOptions(['attributes' => ['rel' => ['prev'], 'title' => t('Go to previous page')]]);
$text = new FormattableMarkup('<b>‹</b> @label', ['@label' => $previous->label()]);
$this->assertRaw(\Drupal::l($text, $url), 'Previous page link found.');
$this->assertRaw(Link::fromTextAndUrl($text, $url)->toString(), 'Previous page link found.');
}
if ($up) {
/** @var \Drupal\Core\Url $url */
$url = $up->toUrl();
$url->setOptions(['attributes' => ['title' => t('Go to parent page')]]);
$this->assertRaw(\Drupal::l('Up', $url), 'Up page link found.');
$this->assertRaw(Link::fromTextAndUrl('Up', $url)->toString(), 'Up page link found.');
}
if ($next) {
......@@ -121,7 +122,7 @@ public function checkBookNode(EntityInterface $node, $nodes, $previous, $up, $ne
$url = $next->toUrl();
$url->setOptions(['attributes' => ['rel' => ['next'], 'title' => t('Go to next page')]]);
$text = new FormattableMarkup('@label <b>›</b>', ['@label' => $next->label()]);
$this->assertRaw(\Drupal::l($text, $url), 'Next page link found.');
$this->assertRaw(Link::fromTextAndUrl($text, $url)->toString(), 'Next page link found.');
}
// Compute the expected breadcrumb.
......
......@@ -20,6 +20,7 @@
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\field\FieldConfigInterface;
use Drupal\field\FieldStorageConfigInterface;
......@@ -678,17 +679,17 @@ function template_preprocess_comment(&$variables) {
}
if (isset($comment->in_preview)) {
$variables['title'] = \Drupal::l($comment->getSubject(), new Url('<front>'));
$variables['permalink'] = \Drupal::l(t('Permalink'), new Url('<front>'));
$variables['title'] = Link::fromTextAndUrl($comment->getSubject(), Url::fromRoute('<front>'))->toString();
$variables['permalink'] = Link::fromTextAndUrl(t('Permalink'), Url::fromRoute('<front>'))->toString();
}
else {
$uri = $comment->permalink();
$attributes = $uri->getOption('attributes') ?: [];
$attributes += ['class' => ['permalink'], 'rel' => 'bookmark'];
$uri->setOption('attributes', $attributes);
$variables['title'] = \Drupal::l($comment->getSubject(), $uri);
$variables['title'] = Link::fromTextAndUrl($comment->getSubject(), $uri)->toString();
$variables['permalink'] = \Drupal::l(t('Permalink'), $comment->permalink());
$variables['permalink'] = Link::fromTextAndUrl(t('Permalink'), $comment->permalink())->toString();
}
$variables['submitted'] = t('Submitted by @username on @datetime', ['@username' => $variables['author'], '@datetime' => $variables['created']]);
......@@ -715,8 +716,8 @@ function template_preprocess_comment(&$variables) {
$attributes = $permalink_uri_parent->getOption('attributes') ?: [];
$attributes += ['class' => ['permalink'], 'rel' => 'bookmark'];
$permalink_uri_parent->setOption('attributes', $attributes);
$variables['parent_title'] = \Drupal::l($comment_parent->getSubject(), $permalink_uri_parent);
$variables['parent_permalink'] = \Drupal::l(t('Parent permalink'), $permalink_uri_parent);
$variables['parent_title'] = Link::fromTextAndUrl($comment_parent->getSubject(), $permalink_uri_parent)->toString();
$variables['parent_permalink'] = Link::fromTextAndUrl(t('Parent permalink'), $permalink_uri_parent)->toString();
$variables['parent'] = t('In reply to @parent_title by @parent_username',
['@parent_username' => $variables['parent_author'], '@parent_title' => $variables['parent_title']]);
}
......
......@@ -4,6 +4,7 @@
use Drupal\comment\CommentManagerInterface;
use Drupal\Core\Session\AnonymousUserSession;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\field\Entity\FieldConfig;
......@@ -81,7 +82,7 @@ public function testLinkApprove() {
$approve_comment = $view->style_plugin->getField(0, 'approve_comment');
$options = ['query' => ['destination' => '/']];
$url = Url::fromRoute('comment.approve', ['comment' => $comment->id()], $options);
$this->assertEqual(\Drupal::l('Approve', $url), (string) $approve_comment, 'Found a comment approve link for an unapproved comment.');
$this->assertEqual(Link::fromTextAndUrl('Approve', $url)->toString(), (string) $approve_comment, 'Found a comment approve link for an unapproved comment.');
// Approve the comment.
$comment->setPublished();
......@@ -181,7 +182,7 @@ public function testLinkReply() {
'field_name' => 'comment',
'pid' => $comment->id(),
]);
$this->assertEqual(\Drupal::l('Reply', $url), (string) $replyto_comment, 'Found the comment reply link as an admin user.');
$this->assertEqual(Link::fromTextAndUrl('Reply', $url)->toString(), (string) $replyto_comment, 'Found the comment reply link as an admin user.');
// Check if I can see the reply link as an anonymous user.
$account_switcher->switchTo(new AnonymousUserSession());
......
......@@ -7,6 +7,7 @@
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Database\Database;
use Drupal\Core\Logger\RfcLogLevel;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\dblog\Controller\DbLogController;
use Drupal\Tests\BrowserTestBase;
......@@ -307,7 +308,7 @@ public function verifySort($sort = 'asc', $order = 'Date') {
* page.
*/
private function verifyLinkEscaping() {
$link = \Drupal::l('View', Url::fromRoute('entity.node.canonical', ['node' => 1]));
$link = Link::fromTextAndUrl('View', Url::fromRoute('entity.node.canonical', ['node' => 1]))->toString();
$message = 'Log entry added to do the verifyLinkEscaping test.';
$this->generateLogEntries(1, [
'message' => $message,
......
......@@ -5,6 +5,7 @@
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Logger\RfcLogLevel;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Views;
......@@ -177,12 +178,15 @@ protected function createLogEntries() {
// Setup a watchdog entry without tokens.
$entries[] = [
'message' => $this->randomMachineName(),
'variables' => ['link' => \Drupal::l('Link', new Url('<front>'))],
'variables' => ['link' => Link::fromTextAndUrl('Link', Url::fromRoute('<front>'))->toString()],
];
// Setup a watchdog entry with one token.
$entries[] = [
'message' => '@token1',
'variables' => ['@token1' => $this->randomMachineName(), 'link' => \Drupal::l('Link', new Url('<front>'))],
'variables' => [
'@token1' => $this->randomMachineName(),
'link' => Link::fromTextAndUrl('Link', Url::fromRoute('<front>'))->toString(),
],
];
// Setup a watchdog entry with two tokens.
$entries[] = [
......
......@@ -15,6 +15,7 @@
use Drupal\field\FieldStorageConfigInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Link;
use Drupal\Core\Url;
/*
......@@ -111,7 +112,7 @@ function field_help($route_name, RouteMatchInterface $route_match) {
if (isset($modules[$provider])) {
$display = \Drupal::moduleHandler()->getName($provider);
if (\Drupal::moduleHandler()->implementsHook($provider, 'help')) {
$items[] = \Drupal::l($display, new Url('help.page', ['name' => $provider]));
$items[] = Link::fromTextAndUrl($display, Url::fromRoute('help.page', ['name' => $provider]))->toRenderable();
}
else {
$items[] = $display;
......
......@@ -10,6 +10,7 @@
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Field\FieldTypePluginManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Link;
/**
* Defines a class to build a listing of fields.
......@@ -122,7 +123,7 @@ public function buildRow(EntityInterface $field_storage) {
$usage = [];
foreach ($field_storage->getBundles() as $bundle) {
if ($route_info = FieldUI::getOverviewRouteInfo($entity_type_id, $bundle)) {
$usage[] = \Drupal::l($this->bundles[$entity_type_id][$bundle]['label'], $route_info);
$usage[] = Link::fromTextAndUrl($this->bundles[$entity_type_id][$bundle]['label'], $route_info)->toRenderable();
}
else {
$usage[] = $this->bundles[$entity_type_id][$bundle]['label'];
......
......@@ -14,6 +14,7 @@
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\Core\Render\Element;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\file\Entity\File;
use Drupal\file\FileInterface;
......@@ -1504,7 +1505,7 @@ function template_preprocess_file_link(&$variables) {
$variables['attributes']->addClass($classes);
$variables['file_size'] = format_size($file->getSize());
$variables['link'] = \Drupal::l($link_text, Url::fromUri($url, $options));
$variables['link'] = Link::fromTextAndUrl($link_text, Url::fromUri($url, $options))->toString();
}
/**
......
......@@ -9,6 +9,7 @@
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
......@@ -446,11 +447,11 @@ function template_preprocess_forums(&$variables) {
if ($variables['tid'] != $topic->forum_tid) {
$variables['topics'][$id]->moved = TRUE;
$variables['topics'][$id]->title = $topic->getTitle();
$variables['topics'][$id]->message = \Drupal::l(t('This topic has been moved'), new Url('forum.page', ['taxonomy_term' => $topic->forum_tid]));
$variables['topics'][$id]->message = Link::fromTextAndUrl(t('This topic has been moved'), Url::fromRoute('forum.page', ['taxonomy_term' => $topic->forum_tid]))->toString();
}
else {
$variables['topics'][$id]->moved = FALSE;
$variables['topics'][$id]->title_link = \Drupal::l($topic->getTitle(), $topic->toUrl());
$variables['topics'][$id]->title_link = Link::fromTextAndUrl($topic->getTitle(), $topic->toUrl())->toString();
$variables['topics'][$id]->message = '';
}
$forum_submitted = [
......
......@@ -5,6 +5,7 @@
* Defines simple link field types.
*/
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\Core\Routing\RouteMatchInterface;
......@@ -62,5 +63,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();
}
......@@ -5,6 +5,7 @@
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\field\Entity\FieldConfig;
......@@ -342,7 +343,7 @@ public function testLinkTitle() {
$this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
$output = $this->renderTestEntity($id);
$expected_link = (string) \Drupal::l($value, Url::fromUri($value));
$expected_link = (string) Link::fromTextAndUrl($value, Url::fromUri($value))->toString();
$this->assertContains($expected_link, $output);
// Verify that a link with text is rendered using the link text.
......@@ -354,7 +355,7 @@ public function testLinkTitle() {
$this->assertText(t('entity_test @id has been updated.', ['@id' => $id]));
$output = $this->renderTestEntity($id);
$expected_link = (string) \Drupal::l($title, Url::fromUri($value));
$expected_link = (string) Link::fromTextAndUrl($title, Url::fromUri($value))->toString();
$this->assertContains($expected_link, $output);
}
......
......@@ -7,6 +7,7 @@
use Drupal\Core\File\Exception\FileException;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Link;
use Drupal\Core\Url;
/**
......@@ -272,7 +273,7 @@ function locale_requirements($phase) {
if ($available_updates) {
$requirements['locale_translation'] = [
'title' => t('Translation update status'),
'value' => \Drupal::l(t('Updates available'), new Url('locale.translate_status')),
'value' => Link::fromTextAndUrl(t('Updates available'), Url::fromRoute('locale.translate_status'))->toString(),
'severity' => REQUIREMENT_WARNING,
'description' => t('Updates available for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', ['@languages' => implode(', ', $available_updates), ':updates' => Url::fromRoute('locale.translate_status')->toString()]),
];
......@@ -297,7 +298,7 @@ function locale_requirements($phase) {
else {
$requirements['locale_translation'] = [
'title' => t('Translation update status'),
'value' => \Drupal::l(t('Can not determine status'), new Url('locale.translate_status')),
'value' => Link::fromTextAndUrl(t('Can not determine status'), Url::fromRoute('locale.translate_status'))->toString(),
'severity' => REQUIREMENT_WARNING,
'description' => t('No translation status is available. See the <a href=":updates">Available translation updates</a> page for more information.', [':updates' => Url::fromRoute('locale.translate_status')->toString()]),
];
......
......@@ -17,6 +17,7 @@
use Drupal\Component\Utility\Xss;
use Drupal\Core\File\Exception\FileException;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\Core\Asset\AttachedAssetsInterface;
use Drupal\Core\Form\FormStateInterface;
......@@ -647,16 +648,14 @@ function locale_form_language_admin_overview_form_alter(&$form, FormStateInterfa
'ratio' => 0,
];
if (!$language->isLocked() && locale_is_translatable($langcode)) {
$form['languages'][$langcode]['locale_statistics'] = [
'#markup' => \Drupal::l(
t('@translated/@total (@ratio%)', [
'@translated' => $stats[$langcode]['translated'],
'@total' => $total_strings,
'@ratio' => $stats[$langcode]['ratio'],
]),
new Url('locale.translate_page', [], ['query' => ['langcode' => $langcode]])
),
];
$form['languages'][$langcode]['locale_statistics'] = Link::fromTextAndUrl(
t('@translated/@total (@ratio%)', [
'@translated' => $stats[$langcode]['translated'],
'@total' => $total_strings,
'@ratio' => $stats[$langcode]['ratio'],
]),
Url::fromRoute('locale.translate_page', [], ['query' => ['langcode' => $langcode]])
)->toRenderable();
}
else {
$form['languages'][$langcode]['locale_statistics'] = [
......
......@@ -5,6 +5,7 @@
* Interface translation summary, editing and deletion user interfaces.
*/
use Drupal\Core\Link;
use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\RedirectResponse;
......@@ -77,5 +78,5 @@ function template_preprocess_locale_translation_last_check(array &$variables) {
$last = $variables['last'];
$variables['last_checked'] = ($last != NULL);
$variables['time'] = \Drupal::service('date.formatter')->formatTimeDiffSince($last);
$variables['link'] = \Drupal::l(t('Check manually'), new Url('locale.check_translation', [], ['query' => \Drupal::destination()->getAsArray()]));
$variables['link'] = Link::fromTextAndUrl(t('Check manually'), Url::fromRoute('locale.check_translation', [], ['query' => \Drupal::destination()->getAsArray()]))->toString();
}
......@@ -5,6 +5,7 @@
* Content administration and module settings user interface.
*/
use Drupal\Core\Link;
use Drupal\node\NodeInterface;
/**
......@@ -134,7 +135,7 @@ function _node_mass_update_batch_process(array $nodes, array $updates, $langcode
$node = _node_mass_update_helper($node, $updates, $langcode);
// Store result for post-processing in the finished callback.
$context['results'][] = \Drupal::l($node->label(), $node->toUrl());
$context['results'][] = Link::fromTextAndUrl($node->label(), $node->toUrl())->toString();
// Update our progress information.
$context['sandbox']['progress']++;
......
......@@ -17,6 +17,7 @@
use Drupal\Core\Database\StatementInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Link;
use Drupal\Core\Render\Element;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface;
......@@ -226,7 +227,7 @@ function node_title_list(StatementInterface $result, $title = NULL) {
// database rows, not actual nodes.
$nids[] = $row->nid;
$options = !empty($row->comment_count) ? ['attributes' => ['title' => \Drupal::translation()->formatPlural($row->comment_count, '1 comment', '@count comments')]] : [];
$items[] = \Drupal::l($row->title, new Url('entity.node.canonical', ['node' => $row->nid], $options));
$items[] = Link::fromTextAndUrl($row->title, Url::fromRoute('entity.node.canonical', ['node' => $row->nid], $options))->toString();
$num_rows = TRUE;
}
......@@ -545,7 +546,7 @@ function template_preprocess_node_add_list(&$variables) {
foreach ($variables['content'] as $type) {
$variables['types'][$type->id()] = [
'type' => $type->id(),
'add_link' => \Drupal::l($type->label(), new Url('node.add', ['node_type' => $type->id()])),
'add_link' => Link::fromTextAndUrl($type->label(), Url::fromRoute('node.add', ['node_type' => $type->id()]))->toString(),
'description' => [
'#markup' => $type->getDescription(),
],
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\node\Functional;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
......@@ -114,7 +115,7 @@ public function testNodeRevisionDoubleEscapeFix() {
// Assert the old revision message.
$date = $this->container->get('date.formatter')->format($nodes[0]->revision_timestamp->value, 'short');
$url = new Url('entity.node.revision', ['node' => $nodes[0]->id(), 'node_revision' => $nodes[0]->getRevisionId()]);
$this->assertRaw(\Drupal::l($date, $url) . ' by ' . $editor);
$this->assertRaw(Link::fromTextAndUrl($date, $url)->toString() . ' by ' . $editor);
// Assert the current revision message.
$date = $this->container->get('date.formatter')->format($nodes[1]->revision_timestamp->value, 'short');
......
......@@ -3,6 +3,7 @@
namespace Drupal\Tests\search\Functional;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\search\Entity\SearchPage;
use Drupal\Tests\BrowserTestBase;
......@@ -48,7 +49,7 @@ protected function setUp() {
// Link the node to itself to test that it's only indexed once. The content
// also needs the word "pizza" so we can use it as the search keyword.
$body_key = 'body[0][value]';
$edit[$body_key] = \Drupal::l($node->label(), $node->toUrl()) . ' pizza sandwich';
$edit[$body_key] = Link::fromTextAndUrl($node->label(), $node->toUrl())->toString() . ' pizza sandwich';
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
$this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
......
......@@ -5,6 +5,7 @@
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\Core\Database\Database;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\filter\Entity\FilterFormat;
use Drupal\search\Entity\SearchPage;
......@@ -224,7 +225,7 @@ public function testHTMLRankings() {
foreach ($shuffled_tags as $tag) {
switch ($tag) {
case 'a':
$settings['body'] = [['value' => \Drupal::l('Drupal Rocks', new Url('<front>')), 'format' => 'full_html']];
$settings['body'] = [['value' => Link::fromTextAndUrl('Drupal Rocks', Url::fromRoute('<front>'))->toString(), 'format' => 'full_html']];
break;
case 'notag':
$settings['body'] = [['value' => 'Drupal Rocks']];
......
......@@ -4,6 +4,7 @@
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Link;
/**
* Form handler for the shortcut entity forms.
......@@ -40,7 +41,7 @@ public function save(array $form, FormStateInterface $form_state) {
// 'link to any content', but has no right to access the linked page. So we
// check the access before showing the link.
if ($url->access()) {
$view_link = \Drupal::l($entity->getTitle(), $url);
$view_link = Link::fromTextAndUrl($entity->getTitle(), $url)->toString();
}
else {
$view_link = $entity->getTitle();
......
......@@ -3,6 +3,7 @@
namespace Drupal\Tests\statistics\Functional;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Link;
use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;