Commit a6492ce9 authored by webchick's avatar webchick

Issue #2343651 by xjm, tim.plunkett, Wim Leers, dinarcon, dawehner: Remove...

Issue #2343651 by xjm, tim.plunkett, Wim Leers, dinarcon, dawehner: Remove most remaining l() calls.
parent 9ff46323
......@@ -109,8 +109,8 @@ function authorize_access_allowed() {
}
else {
$links = array_merge($links, array(
l(t('Administration pages'), 'admin'),
l(t('Front page'), '<front>'),
\Drupal::l(t('Administration pages'), 'system.admin'),
\Drupal::l(t('Front page'), '<front>'),
));
}
......
......@@ -948,7 +948,7 @@ function template_preprocess_status_messages(&$variables) {
* class. I.e. we cannot yet convert this jQuery selector to a CSS selector:
* jQuery('li:has("a.active")')
*
* @see l()
* @see \Drupal\Core\Utility\LinkGenerator
* @see \Drupal\Core\Utility\LinkGenerator::generate()
* @see system_page_build()
*/
......
......@@ -133,7 +133,7 @@ public static function filterQueryParameters(array $query, array $exclude = arra
* - query: An array of query parameters from $url, if they exist.
* - fragment: The fragment component from $url, if it exists.
*
* @see l()
* @see \Drupal\Core\Utility\LinkGenerator
* @see url()
* @see http://tools.ietf.org/html/rfc3986
*
......
......@@ -98,9 +98,9 @@ public function getSchemaUpdates() {
*/
public function postInstallTasks() {
return array(
l(t('Install another module'), 'admin/modules/install'),
l(t('Enable newly added modules'), 'admin/modules'),
l(t('Administration pages'), 'admin'),
\Drupal::l(t('Install another module'), 'update.module_install'),
\Drupal::l(t('Enable newly added modules'), 'system.modules_list'),
\Drupal::l(t('Administration pages'), 'system.admin'),
);
}
......
......@@ -82,8 +82,8 @@ public function postInstall() {
*/
public function postInstallTasks() {
return array(
l(t('Install newly added themes'), 'admin/appearance'),
l(t('Administration pages'), 'admin'),
\Drupal::l(t('Install newly added themes'), 'system.themes_page'),
\Drupal::l(t('Administration pages'), 'system.admin'),
);
}
}
......@@ -121,7 +121,7 @@ public function adminOverview() {
$rows = array();
foreach ($feeds as $feed) {
$row = array();
$row[] = l($feed->label(), "aggregator/sources/" . $feed->id());
$row[] = $this->getLinkGenerator()->generateFromUrl($feed->label(), $feed->urlInfo());
$row[] = $this->dateFormatter->formatInterval($entity_manager->getStorage('aggregator_item')->getItemCount($feed), '1 item', '@count items');
$last_checked = $feed->getLastCheckedTime();
$refresh_rate = $feed->getRefreshRate();
......
......@@ -70,7 +70,7 @@ public function save(array $form, FormStateInterface $form_state) {
$form_state->setRedirectUrl($feed->urlInfo('canonical'));
}
else {
$this->logger('aggregator')->notice('Feed %feed added.', array('%feed' => $feed->label(), 'link' => l($this->t('View'), 'admin/config/services/aggregator')));
$this->logger('aggregator')->notice('Feed %feed added.', array('%feed' => $feed->label(), 'link' => \Drupal::l($this->t('View'), 'aggregator.admin_overview')));
drupal_set_message($this->t('The feed %feed has been added.', array('%feed' => $feed->label())));
}
}
......
......@@ -41,7 +41,7 @@ function block_help($route_name, RouteMatchInterface $route_match) {
$demo_theme = $route_match->getParameter('theme') ?: \Drupal::config('system.theme')->get('default');
$themes = list_themes();
$output = '<p>' . t('This page provides a drag-and-drop interface for adding a block to a region, and for controlling the order of blocks within regions. To add a block to a region, or to configure its specific title and visibility settings, click the block title under <em>Place blocks</em>. Since not all themes implement the same regions, or display regions in the same way, blocks are positioned on a per-theme basis. Remember that your changes will not be saved until you click the <em>Save blocks</em> button at the bottom of the page.') . '</p>';
$output .= '<p>' . l(t('Demonstrate block regions (!theme)', array('!theme' => $themes[$demo_theme]->info['name'])), 'admin/structure/block/demo/' . $demo_theme) . '</p>';
$output .= '<p>' . \Drupal::l(t('Demonstrate block regions (!theme)', array('!theme' => $themes[$demo_theme]->info['name'])), 'block.admin_demo', array('theme' => $demo_theme)) . '</p>';
return $output;
}
}
......
......@@ -518,7 +518,10 @@ function theme_book_link(array $variables) {
$sub_menu = drupal_render($element['#below']);
}
$element['#localized_options']['set_active_class'] = TRUE;
$output = l($element['#title'], $element['#href'], $element['#localized_options']);
/** @var \Drupal\Core\Url $url */
$url = $element['#url'];
$url->setOptions($element['#localized_options'] + $url->getOptions());
$output = \Drupal::linkGenerator()->generateFromUrl($element['#title'], $url);
return '<li' . new Attribute($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
......
......@@ -99,7 +99,7 @@ protected function loadBooks() {
foreach ($book_links as $link) {
$nid = $link['nid'];
if (isset($nodes[$nid]) && $nodes[$nid]->status) {
$link['link_path'] = 'node/' . $nid;
$link['url'] = $nodes[$nid]->urlInfo();
$link['title'] = $nodes[$nid]->label();
$link['type'] = $nodes[$nid]->bundle();
$this->books[$link['bid']] = $link;
......@@ -528,7 +528,7 @@ public function bookTreeOutput(array $tree) {
$element['#attributes']['class'] = $class;
$element['#title'] = $data['link']['title'];
$node = $this->entityManager->getStorage('node')->load($data['link']['nid']);
$element['#href'] = $node->url();
$element['#url'] = $node->urlInfo();
$element['#localized_options'] = !empty($data['link']['localized_options']) ? $data['link']['localized_options'] : array();
$element['#below'] = $data['below'] ? $this->bookTreeOutput($data['below']) : $data['below'];
$element['#original_link'] = $data['link'];
......
......@@ -9,7 +9,7 @@
use Drupal\book\BookExport;
use Drupal\book\BookManagerInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Controller\ControllerBase;
use Drupal\node\NodeInterface;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -19,7 +19,7 @@
/**
* Controller routines for book routes.
*/
class BookController implements ContainerInjectionInterface {
class BookController extends ControllerBase {
/**
* The book manager.
......@@ -71,8 +71,13 @@ public function adminOverview() {
$headers = array(t('Book'), t('Operations'));
// Add any recognized books to the table list.
foreach ($this->bookManager->getAllBooks() as $book) {
/** @var \Drupal\Core\Url $url */
$url = $book->urlInfo();
if (isset($book['options'])) {
$url->setOptions($book['options']);
}
$row = array(
l($book['title'], $book['link_path'], isset($book['options']) ? $book['options'] : array()),
$this->getLinkGenerator()->generateFromUrl($book['title'], $url),
);
$links = array();
$links['edit'] = array(
......@@ -105,7 +110,7 @@ public function adminOverview() {
public function bookRender() {
$book_list = array();
foreach ($this->bookManager->getAllBooks() as $book) {
$book_list[] = l($book['title'], $book['link_path']);
$book_list[] = $this->getLinkGenerator()->generateFromUrl($book['title'], $book['url']);
}
return array(
'#theme' => 'item_list',
......
......@@ -121,7 +121,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$node->book['link_title'] = $values['title'];
$node->setNewRevision();
$node->save();
$this->logger('content')->notice('book: updated %title.', array('%title' => $node->label(), 'link' => l($this->t('View'), 'node/' . $node->id())));
$this->logger('content')->notice('book: updated %title.', array('%title' => $node->label(), 'link' => $this->getLinkGenerator()->generateFromUrl($this->t('View'), $node->urlInfo())));
}
}
}
......
......@@ -187,15 +187,24 @@ function checkBookNode(EntityInterface $node, $nodes, $previous = FALSE, $up = F
// Check previous, up, and next links.
if ($previous) {
$this->assertRaw(l('<b>‹</b> ' . $previous->label(), 'node/' . $previous->id(), array('html' => TRUE, 'attributes' => array('rel' => array('prev'), 'title' => t('Go to previous page')))), 'Previous page link found.');
/** @var \Drupal\Core\Url $url */
$url = $previous->urlInfo();
$url->setOptions(array('html' => TRUE, 'attributes' => array('rel' => array('prev'), 'title' => t('Go to previous page'))));
$this->assertRaw(\Drupal::linkGenerator()->generateFromUrl('<b>‹</b> ' . $previous->label(), $url), 'Previous page link found.');
}
if ($up) {
$this->assertRaw(l('Up', 'node/' . $up->id(), array('html'=> TRUE, 'attributes' => array('title' => t('Go to parent page')))), 'Up page link found.');
/** @var \Drupal\Core\Url $url */
$url = $up->urlInfo();
$url->setOptions(array('html'=> TRUE, 'attributes' => array('title' => t('Go to parent page'))));
$this->assertRaw(\Drupal::linkGenerator()->generateFromUrl('Up', $url), 'Up page link found.');
}
if ($next) {
$this->assertRaw(l($next->label() . ' <b>›</b>', 'node/' . $next->id(), array('html'=> TRUE, 'attributes' => array('rel' => array('next'), 'title' => t('Go to next page')))), 'Next page link found.');
/** @var \Drupal\Core\Url $url */
$url = $next->urlInfo();
$url->setOptions(array('html'=> TRUE, 'attributes' => array('rel' => array('next'), 'title' => t('Go to next page'))));
$this->assertRaw(\Drupal::linkGenerator()->generateFromUrl($next->label() . ' <b>›</b>', $url), 'Next page link found.');
}
// Compute the expected breadcrumb.
......
......@@ -727,8 +727,8 @@ function template_preprocess_comment(&$variables) {
$variables['signature'] = '';
}
if (isset($comment->in_preview)) {
$variables['title'] = l($comment->getSubject(), '');
$variables['permalink'] = l(t('Permalink'), '');
$variables['title'] = \Drupal::l($comment->getSubject(), '<front>');
$variables['permalink'] = \Drupal::l(t('Permalink'), '<front>');
}
else {
$uri = $comment->urlInfo();
......
......@@ -370,7 +370,10 @@ public function save(array $form, FormStateInterface $form_state) {
$form_state->setValue('cid', $comment->id());
// Add a log entry.
$logger->notice('Comment posted: %subject.', array('%subject' => $comment->getSubject(), 'link' => l(t('View'), 'comment/' . $comment->id(), array('fragment' => 'comment-' . $comment->id()))));
$logger->notice('Comment posted: %subject.', array(
'%subject' => $comment->getSubject(),
'link' => $this->getLinkGenerator()->generateFromUrl(t('View'), $comment->urlInfo()->setOption('fragment', 'comment-' . $comment->id()))
));
// Explain the approval queue if necessary.
if (!$comment->isPublished()) {
......
......@@ -122,11 +122,13 @@ public function overview(Request $request, $entity_type_id = NULL) {
$source = isset($entity->translation[$langcode]['source']) ? $entity->translation[$langcode]['source'] : '';
$is_original = $langcode == $original;
$label = $entity->getTranslation($langcode)->label();
$link = isset($links->links[$langcode]['href']) ? $links->links[$langcode] : array('href' => $entity->getSystemPath());
$link += array('language' => $language);
$row_title = l($label, $link['href'], $link);
$link = isset($links->links[$langcode]['url']) ? $links->links[$langcode] : array('url' => $entity->urlInfo());
if (!empty($link['url'])) {
$link['url']->setOption('language', $language);
$row_title = $this->getLinkGenerator()->generateFromUrl($label, $link['url']);
}
if (empty($link['href'])) {
if (empty($link['url'])) {
$row_title = $is_original ? $label : $this->t('n/a');
}
......@@ -134,10 +136,7 @@ public function overview(Request $request, $entity_type_id = NULL) {
// the entity form, otherwise if we are not dealing with the original
// language we point the link to the translation form.
if ($entity->access('update')) {
$links['edit'] = array(
'href' => $entity->getSystemPath('edit-form'),
'language' => $language,
);
$links['edit'] = $entity->urlInfo('edit-form')->toArray() + ['language' => $language];
}
elseif (!$is_original && $handler->getTranslationAccess($entity, 'update')->isAllowed()) {
$links['edit'] = $edit_url->toArray();
......
......@@ -51,7 +51,7 @@ public function defaultValuesForm(array &$form, FormStateInterface $form_state)
'default_date' => array(
'#type' => 'textfield',
'#title' => t('Relative default value'),
'#description' => t("Describe a time by reference to the current day, like '+90 days' (90 days from the day the field is created) or '+1 Saturday' (the next Saturday). See !strtotime for more details.", array('!strtotime' => l('strtotime', 'http://www.php.net/manual/en/function.strtotime.php'))),
'#description' => t("Describe a time by reference to the current day, like '+90 days' (90 days from the day the field is created) or '+1 Saturday' (the next Saturday). See <a href=\"@url\">@strtotime</a> for more details.", array('@strtotime' => 'strtotime', '@url' => 'http://www.php.net/manual/en/function.strtotime.php')),
'#default_value' => (isset($default_value[0]['default_date_type']) && $default_value[0]['default_date_type'] == static::DEFAULT_VALUE_CUSTOM) ? $default_value[0]['default_date'] : '',
'#states' => array(
'visible' => array(
......
......@@ -40,6 +40,9 @@ class ViewsIntegrationTest extends ViewUnitTestBase {
protected function setUp() {
parent::setUp();
// Rebuild the router, otherwise we can't generate links.
$this->container->get('router.builder')->rebuild();
$this->installSchema('dblog', array('watchdog'));
ViewTestData::createTestViews(get_class($this), array('dblog_test_views'));
......@@ -57,12 +60,12 @@ public function testIntegration() {
// Setup a watchdog entry without tokens.
$entries[] = array(
'message' => $this->randomMachineName(),
'variables' => array('link' => l('Link', 'node/1')),
'variables' => array('link' => \Drupal::l('Link', '<front>')),
);
// Setup a watchdog entry with one token.
$entries[] = array(
'message' => '@token1',
'variables' => array('@token1' => $this->randomMachineName(), 'link' => l('Link', 'node/2')),
'variables' => array('@token1' => $this->randomMachineName(), 'link' => \Drupal::l('Link', '<front>')),
);
// Setup a watchdog entry with two tokens.
$entries[] = array(
......@@ -72,7 +75,7 @@ public function testIntegration() {
'variables' => array(
'@token1' => $this->randomMachineName(),
'!token2' => $this->randomMachineName(),
'link' => l('<object>Link</object>', 'node/2', array('html' => TRUE)),
'link' => \Drupal::l('<object>Link</object>', '<front>'),
),
);
$logger_factory = $this->container->get('logger.factory');
......
......@@ -86,7 +86,7 @@ function field_help($route_name, RouteMatchInterface $route_match) {
if (isset($info[$provider]['name'])) {
$display = $info[$provider]['name'];
if (\Drupal::moduleHandler()->implementsHook($provider, 'help')) {
$items[] = l($display, 'admin/help/' . $provider);
$items[] = \Drupal::l($display, 'help.page', array('name' => $provider));
}
else {
$items[] = $display;
......
......@@ -179,7 +179,7 @@ public static function processFormat(&$element, FormStateInterface $form_state,
$element['format']['help'] = array(
'#type' => 'container',
'#attributes' => array('class' => array('filter-help')),
'#markup' => l(t('About text formats'), 'filter/tips', array('attributes' => array('target' => '_blank'))),
'#markup' => \Drupal::l(t('About text formats'), 'filter.tips_all', array(), array('attributes' => array('target' => '_blank'))),
'#weight' => 0,
);
......
......@@ -536,11 +536,11 @@ function template_preprocess_forums(&$variables) {
if ($variables['tid'] != $topic->forum_tid) {
$variables['topics'][$id]->moved = TRUE;
$variables['topics'][$id]->title = String::checkPlain($topic->getTitle());
$variables['topics'][$id]->message = l(t('This topic has been moved'), "forum/$topic->forum_tid");
$variables['topics'][$id]->message = \Drupal::l(t('This topic has been moved'), 'forum.page', ['taxonomy_term' => $topic->forum_tid]);
}
else {
$variables['topics'][$id]->moved = FALSE;
$variables['topics'][$id]->title_link = l($topic->getTitle(), 'node/' . $topic->id());
$variables['topics'][$id]->title_link = \Drupal::linkGenerator()->generateFromUrl($topic->getTitle(), $topic->urlInfo());
$variables['topics'][$id]->message = '';
}
$forum_submitted = array('#theme' => 'forum_submitted', '#topic' => (object) array(
......
......@@ -79,16 +79,19 @@ public function save(array $form, FormStateInterface $form_state) {
$term_storage = $this->entityManager->getStorage('taxonomy_term');
$status = $term_storage->save($term);
$route_name = $this->urlStub == 'container' ? 'forum.edit_container' : 'forum.edit_forum';
$route_parameters = ['taxonomy_term' => $term->id()];
$link = \Drupal::l($this->t('Edit'), $route_name, $route_parameters);
switch ($status) {
case SAVED_NEW:
drupal_set_message($this->t('Created new @type %term.', array('%term' => $term->getName(), '@type' => $this->forumFormType)));
$this->logger('forum')->notice('Created new @type %term.', array('%term' => $term->getName(), '@type' => $this->forumFormType, 'link' => l($this->t('Edit'), 'admin/structure/forum/edit/' . $this->urlStub . '/' . $term->id())));
$this->logger('forum')->notice('Created new @type %term.', array('%term' => $term->getName(), '@type' => $this->forumFormType, 'link' => $link));
$form_state->setValue('tid', $term->id());
break;
case SAVED_UPDATED:
drupal_set_message($this->t('The @type %term has been updated.', array('%term' => $term->getName(), '@type' => $this->forumFormType)));
$this->logger('forum')->notice('Updated @type %term.', array('%term' => $term->getName(), '@type' => $this->forumFormType, 'link' => l($this->t('Edit'), 'admin/structure/forum/edit/' . $this->urlStub . '/' . $term->id())));
$this->logger('forum')->notice('Updated @type %term.', array('%term' => $term->getName(), '@type' => $this->forumFormType, 'link' => $link));
break;
}
......
......@@ -85,7 +85,7 @@ function _testImageFieldFormatters($scheme) {
'#width' => 40,
'#height' => 20,
);
$default_output = l($image, file_create_url($image_uri), array('html' => TRUE));
$default_output = '<a href="' . file_create_url($image_uri) . '">' . drupal_render($image) . '</a>';
$this->drupalGet('node/' . $nid);
$cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
$this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.');
......
......@@ -260,7 +260,7 @@ function locale_requirements($phase) {
if ($available_updates) {
$requirements['locale_translation'] = array(
'title' => 'Translation update status',
'value' => l(t('Updates available'), 'admin/reports/translations'),
'value' => \Drupal::l(t('Updates available'), 'locale.translate_status'),
'severity' => REQUIREMENT_WARNING,
'description' => t('Updates available for: @languages. See the <a href="@updates">Available translation updates</a> page for more information.', array('@languages' => implode(', ', $available_updates), '@updates' => \Drupal::url('locale.translate_status'))),
);
......@@ -285,7 +285,7 @@ function locale_requirements($phase) {
else {
$requirements['locale_translation'] = array(
'title' => 'Translation update status',
'value' => l(t('Can not determine status'), 'admin/reports/translations'),
'value' => \Drupal::l(t('Can not determine status'), 'locale.translate_status'),
'severity' => REQUIREMENT_WARNING,
'description' => t('No translation status is available. See the <a href="@updates">Available translation updates</a> page for more information.', array('@updates' => \Drupal::url('locale.translate_status'))),
);
......
......@@ -594,13 +594,13 @@ function locale_form_language_admin_overview_form_alter(&$form, FormStateInterfa
);
if (!$language->locked && ($langcode != 'en' || locale_translate_english())) {
$form['languages'][$langcode]['locale_statistics'] = array(
'#markup' => l(
'#markup' => \Drupal::l(
t('@translated/@total (@ratio%)', array(
'@translated' => $stats[$langcode]['translated'],
'@total' => $total_strings,
'@ratio' => $stats[$langcode]['ratio'],
)),
'admin/config/regional/translate',
'locale.translate_page', array(),
array('query' => array('langcode' => $langcode))
),
);
......
......@@ -157,5 +157,5 @@ function template_preprocess_locale_translation_last_check(&$variables) {
$last = $variables['last'];
$variables['last_checked'] = ($last != NULL);
$variables['time'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $last);
$variables['link'] = l(t('Check manually'), 'admin/reports/translations/check', array('query' => drupal_get_destination()));
$variables['link'] = \Drupal::l(t('Check manually'), 'locale.check_translation', array(), array('query' => drupal_get_destination()));
}
......@@ -128,7 +128,7 @@ function _node_mass_update_batch_process(array $nodes, array $updates, $load, $r
$node = _node_mass_update_helper($node, $updates);
// Store result for post-processing in the finished callback.
$context['results'][] = l($node->label(), 'node/' . $node->id());
$context['results'][] = \Drupal::linkGenerator()->generateFromUrl($node->label(), $node->urlInfo());
// Update our progress information.
$context['sandbox']['progress']++;
......
......@@ -32,7 +32,7 @@ function node_requirements($phase) {
'value' => $value,
// The result of t() is safe and so is the result of l(). Preserving
// safe object.
'description' => SafeMarkup::set($description . ' ' . l(t('Rebuild permissions'), 'admin/reports/status/rebuild')),
'description' => SafeMarkup::set($description . ' ' . \Drupal::l(t('Rebuild permissions'), 'node.configure_rebuild_confirm')),
);
}
return $requirements;
......
......@@ -16,6 +16,7 @@
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\Database\StatementInterface;
use Drupal\Core\Database\Query\AlterableInterface;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\field\Entity\FieldStorageConfig;
......@@ -185,7 +186,7 @@ function node_entity_view_display_alter(EntityViewDisplayInterface $display, $co
/**
* Gathers a listing of links to nodes.
*
* @param $result
* @param \Drupal\Core\Database\StatementInterface $result
* A database result object from a query to fetch node entities. If your
* query joins the {comment_entity_statistics} table so that the comment_count
* field is available, a title attribute will be added to show the number of
......@@ -197,12 +198,14 @@ function node_entity_view_display_alter(EntityViewDisplayInterface $display, $co
* A renderable array containing a list of linked node titles fetched from
* $result, or FALSE if there are no rows in $result.
*/
function node_title_list($result, $title = NULL) {
function node_title_list(StatementInterface $result, $title = NULL) {
$items = array();
$num_rows = FALSE;
foreach ($result as $node) {
// Do not use $node->label() here, because $node comes from the database.
$items[] = l($node->title, 'node/' . $node->nid, !empty($node->comment_count) ? array('attributes' => array('title' => format_plural($node->comment_count, '1 comment', '@count comments'))) : array());
foreach ($result as $row) {
// Do not use $node->label() or $node->urlInfo() here, because we only have
// database rows, not actual nodes.
$options = !empty($row->comment_count) ? array('attributes' => array('title' => format_plural($row->comment_count, '1 comment', '@count comments'))) : array();
$items[] = \Drupal::linkGenerator()->generate($row->title, 'entity.node.canonical', ['node' => $row->nid], $options);
$num_rows = TRUE;
}
......
......@@ -31,7 +31,7 @@ function template_preprocess_node_add_list(&$variables) {
foreach ($variables['content'] as $type) {
$variables['types'][$type->type] = array(
'type' => $type->type,
'add_link' => l($type->name, 'node/add/' . $type->type),
'add_link' => \Drupal::l($type->name, 'node.add', array('node_type' => $type->type)),
'description' => Xss::filterAdmin($type->description),
);
}
......
......@@ -408,7 +408,7 @@ public function save(array $form, FormStateInterface $form_state) {
$node = $this->entity;
$insert = $node->isNew();
$node->save();
$node_link = l(t('View'), 'node/' . $node->id());
$node_link = $this->getLinkGenerator()->generateFromUrl(t('View'), $node->urlInfo());
$context = array('@type' => $node->getType(), '%title' => $node->label(), 'link' => $node_link);
$t_args = array('@type' => node_get_type_label($node), '%title' => $node->label());
......
......@@ -230,7 +230,7 @@ public function save(array $form, FormStateInterface $form_state) {
}
elseif ($status == SAVED_NEW) {
drupal_set_message(t('The content type %name has been added.', $t_args));
$context = array_merge($t_args, array('link' => l(t('View'), 'admin/structure/types')));
$context = array_merge($t_args, array('link' => \Drupal::l(t('View'), 'node.overview_types')));
$this->logger('node')->notice('Added content type %name.', $context);
}
......
......@@ -115,7 +115,7 @@ public function _testResponsiveImageFieldFormatters($scheme) {
'#width' => 40,
'#height' => 20,
);
$default_output = l($image, file_create_url($image_uri), array('html' => TRUE));
$default_output = '<a href="' . file_create_url($image_uri) . '">' . drupal_render($image) . '</a>';
$this->drupalGet('node/' . $nid);
$cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
$this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.');
......
......@@ -48,7 +48,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] = l($node->label(), 'node/' . $node->id()) . ' pizza sandwich';
$edit[$body_key] = \Drupal::linkGenerator()->generateFromUrl($node->label(), $node->urlInfo()) . ' pizza sandwich';
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
$this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
......
......@@ -218,7 +218,7 @@ public function testHTMLRankings() {
foreach ($shuffled_tags as $tag) {
switch ($tag) {
case 'a':
$settings['body'] = array(array('value' => l('Drupal Rocks', 'node'), 'format' => 'full_html'));
$settings['body'] = array(array('value' => \Drupal::l('Drupal Rocks', '<front>'), 'format' => 'full_html'));
break;
case 'notag':
$settings['body'] = array(array('value' => 'Drupal Rocks'));
......
......@@ -52,7 +52,7 @@ public function form(array $form, FormStateInterface $form_state) {
foreach ($this->entity->getShortcuts() as $shortcut) {
$id = $shortcut->id();
$form['shortcuts']['links'][$id]['#attributes']['class'][] = 'draggable';
$form['shortcuts']['links'][$id]['name']['#markup'] = l($shortcut->getTitle(), $shortcut->path->value);
$form['shortcuts']['links'][$id]['name']['#markup'] = $this->getLinkGenerator()->generateFromUrl($shortcut->getTitle(), $shortcut->getUrl());
$form['shortcuts']['links'][$id]['#weight'] = $shortcut->getWeight();
$form['shortcuts']['links'][$id]['weight'] = array(
'#type' => 'weight',
......
......@@ -49,7 +49,7 @@ function testPopularContentBlock() {
$this->assertText('All time', 'Found the all time popular content.');
$this->assertText('Last viewed', 'Found the last viewed popular content.');
$this->assertRaw(l($node->label(), 'node/' . $node->id()), 'Found link to visited node.');
$this->assertRaw(\Drupal::linkGenerator()->generateFromUrl($node->label(), $node->urlInfo()), 'Found link to visited node.');
}
}
......@@ -146,41 +146,6 @@ function statistics_get($nid) {
}
}
/**
* Generates a link to a path, truncating the displayed text to a given width.
*
* @param string $path
* The path to generate the link for.
* @param int $width
* The width to set the displayed text of the path.
*
* @return string
* A string as a link, truncated to the width, linked to the given $path.
*/
function _statistics_link($path, $width = 35) {
$title = \Drupal::service('path.alias_manager')->getAliasByPath($path);
$title = truncate_utf8($title, $width, FALSE, TRUE);
return l($title, $path);
}
/**
* Formats an item for display, including both the item title and the link.
*
* @param string $title
* The text to link to a path; will be truncated to a maximum width of 35.
* @param string $path
* The path to link to; will default to '/'.
*
* @return string
* An HTML string with $title linked to the $path.
*/
function _statistics_format_item($title, $path) {
$path = ($path ? $path : '/');
$output = ($title ? "$title<br />" : '');
$output .= _statistics_link($path);
return $output;
}
/**
* Implements hook_ENTITY_TYPE_predelete() for node entities.
*/
......
......@@ -33,7 +33,7 @@ function syslog_help($route_name, RouteMatchInterface $route_match) {
*/
function syslog_form_system_logging_settings_alter(&$form, FormStateInterface $form_state) {
$config = \Drupal::config('syslog.settings');
$help = \Drupal::moduleHandler()->moduleExists('help') ? ' ' . l(t('More information'), 'admin/help/syslog') . '.' : NULL;
$help = \Drupal::moduleHandler()->moduleExists('help') ? ' ' . \Drupal::l(t('More information'), 'help.page', ['name' => 'syslog']) . '.' : NULL;
$form['syslog_identity'] = array(
'#type' => 'textfield',
'#title' => t('Syslog identity'),
......
......@@ -1565,7 +1565,7 @@ function hook_requirements($phase) {
// Test PHP version
$requirements['php'] = array(
'title' => t('PHP'),
'value' => ($phase == 'runtime') ? l(phpversion(), 'admin/reports/status/php') : phpversion(),
'value' => ($phase == 'runtime') ? \Drupal::l(phpversion(), 'system.php') : 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.', array('%version' => DRUPAL_MINIMUM_PHP));
......
......@@ -59,7 +59,7 @@ function system_requirements($phase) {
$requirements['php'] = array(
'title' => t('PHP'),
// $phpversion is safe and output of l() is safe, so this value is safe.
'value' => SafeMarkup::set(($phase == 'runtime') ? $phpversion . ' (' . l(t('more information'), 'admin/reports/status/php') . ')' : $phpversion),
'value' => SafeMarkup::set(($phase == 'runtime') ? $phpversion . ' (' . \Drupal::l(t('more information'), 'system.php') . ')' : $phpversion),
);
}
else {
......
......@@ -1175,10 +1175,10 @@ function system_time_zones($blank = NULL) {
function theme_system_compact_link() {
$output = '<div class="compact-link">';
if (system_admin_compact_mode()) {
$output .= l(t('Show descriptions'), 'admin/compact/off', array('attributes' => array('title' => t('Expand layout to include descriptions.')), 'query' => drupal_get_destination()));
$output .= \Drupal::l(t('Show descriptions'), 'system.admin_compact_page', array('mode' => 'off'), array('attributes' => array('title' => t('Expand layout to include descriptions.')), 'query' => drupal_get_destination()));
}
else {
$output .= l(t('Hide descriptions'), 'admin/compact/on', array('attributes' => array('title' => t('Compress layout by hiding descriptions.')), 'query' => drupal_get_destination()));
$output .= \Drupal::l(t('Hide descriptions'), 'system.admin_compact_page', array('mode' => 'on'), array('attributes' => array('title' => t('Compress layout by hiding descriptions.')), 'query' => drupal_get_destination()));
}
$output .= '</div>';
......
......@@ -68,7 +68,7 @@ public function render(ResultRow $values) {
));
if ($term->access('update')) {
$text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Edit');
return l($text, 'taxonomy/term/'. $tid . '/edit', array('query' => drupal_get_destination()));
return \Drupal::l($text, 'entity.taxonomy.edit_form', ['taxonomy_term' => $tid], array('query' => drupal_get_destination()));