Commit a6492ce9 authored by webchick's avatar webchick
Browse files

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,
);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment