Issue #2364161 by dawehner, mpdonadio, Wim Leers: Replace nearly all existing _l calls.

8.0.x
Alex Pott 2014-11-04 08:30:21 +00:00
parent d3b5655486
commit 46e6a32911
22 changed files with 95 additions and 62 deletions

View File

@ -209,13 +209,10 @@ class TwigExtension extends \Twig_Extension {
* An HTML string containing a link to the given url.
*/
public function getLink($text, $url) {
if ($url instanceof Url) {
return $this->linkGenerator->generate($text, $url);
}
else {
// @todo Convert once https://www.drupal.org/node/2306901 is in
return _l($text, $url);
if (!$url instanceof Url) {
$url = Url::fromUri($url);
}
return $this->linkGenerator->generate($text, $url);
}
/**

View File

@ -7,6 +7,7 @@
namespace Drupal\aggregator\Tests\Views;
use Drupal\Core\Url;
use Drupal\views\Views;
use Drupal\views\Tests\ViewTestData;
use Drupal\views\Tests\ViewUnitTestBase;
@ -107,7 +108,7 @@ class IntegrationTest extends ViewUnitTestBase {
// Ensure that the rendering of the linked title works as expected.
foreach ($view->result as $row) {
$iid = $view->field['iid']->getValue($row);
$expected_link = _l($items[$iid]->getTitle(), $items[$iid]->getLink(), array('absolute' => TRUE));
$expected_link = \Drupal::l($items[$iid]->getTitle(), Url::fromUri($items[$iid]->getLink(), ['absolute' => TRUE]));
$this->assertEqual($view->field['title']->advancedRender($row), $expected_link, 'Ensure the right link is generated');
$expected_author = aggregator_filter_xss($items[$iid]->getAuthor());

View File

@ -254,11 +254,11 @@ class DbLogController extends ControllerBase {
),
array(
array('data' => $this->t('Location'), 'header' => TRUE),
_l($dblog->location, $dblog->location),
$this->l($dblog->location, $dblog->location ? Url::fromUri('base://' . $dblog->location) : Url::fromRoute('<none>')),
),
array(
array('data' => $this->t('Referrer'), 'header' => TRUE),
_l($dblog->referer, $dblog->referer),
$this->l($dblog->referer, $dblog->referer ? Url::fromUri('base://' . $dblog->referer) : Url::fromRoute('<none>')),
),
array(
array('data' => $this->t('Message'), 'header' => TRUE),

View File

@ -11,6 +11,7 @@ use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Drupal\file\Entity\File;
use Drupal\file\FileInterface;
use Drupal\Component\Utility\NestedArray;
@ -1259,7 +1260,7 @@ function template_preprocess_file_link(&$variables) {
$options['attributes']['title'] = String::checkPlain($file_entity->getFilename());
}
$variables['link'] = _l($link_text, $url, $options);
$variables['link'] = \Drupal::l($link_text, Url::fromUri($url, $options));
$variables['attributes'] = array('class' => array('file'));
}

View File

@ -64,10 +64,5 @@ function template_preprocess_link_formatter_link_separate(&$variables) {
$variables['title'] = String::checkPlain($variables['title']);
}
if (!$variables['url']->isExternal()) {
$variables['link'] = \Drupal::l($variables['url_title'], $variables['url']);
}
else {
$variables['link'] = _l($variables['url_title'], $variables['url']->getUri(), $variables['url']->getOptions());
}
$variables['link'] = \Drupal::l($variables['url_title'], $variables['url']);
}

View File

@ -9,6 +9,7 @@ namespace Drupal\link\Tests;
use Drupal\Component\Utility\String;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Url;
use Drupal\link\LinkItemInterface;
use Drupal\simpletest\WebTestBase;
@ -276,7 +277,7 @@ class LinkFieldTest extends WebTestBase {
$this->assertText(t('entity_test @id has been created.', array('@id' => $id)));
$this->renderTestEntity($id);
$expected_link = _l($value, $value);
$expected_link = \Drupal::l($value, Url::fromUri($value));
$this->assertRaw($expected_link);
// Verify that a link with text is rendered using the link text.
@ -288,7 +289,7 @@ class LinkFieldTest extends WebTestBase {
$this->assertText(t('entity_test @id has been updated.', array('@id' => $id)));
$this->renderTestEntity($id);
$expected_link = _l($title, $value);
$expected_link = \Drupal::l($title, Url::fromUri($value));
$this->assertRaw($expected_link);
}

View File

@ -89,10 +89,10 @@ class PathController extends ControllerBase {
$row['data']['alias'] = _l(Unicode::truncate($data->alias, 50, FALSE, TRUE), $data->source, array(
'attributes' => array('title' => $data->alias),
));
$row['data']['source'] = _l(Unicode::truncate($data->source, 50, FALSE, TRUE), $data->source, array(
$row['data']['source'] = $this->l(Unicode::truncate($data->source, 50, FALSE, TRUE), Url::fromUri('base://' . $data->source, array(
'alias' => TRUE,
'attributes' => array('title' => $data->source),
));
)));
if ($multilanguage) {
$row['data']['language_name'] = $this->languageManager()->getLanguageName($data->langcode);
}

View File

@ -8,6 +8,7 @@
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Routing\RouteMatchInterface;
use \Drupal\Core\Template\Attribute;
use Drupal\Core\Url;
use Drupal\responsive_image\Entity\ResponsiveImageMapping;
/**
@ -151,7 +152,7 @@ function theme_responsive_image_formatter($variables) {
$path = $variables['path']['path'];
$options = isset($variables['path']['options']) ? $variables['path']['options'] : array();
$options['html'] = TRUE;
return _l($responsive_image, $path, $options);
return \Drupal::l($responsive_image, Url::fromUri($path, $options));
}
return drupal_render($responsive_image);

View File

@ -134,11 +134,11 @@ class UrlTest extends WebTestBase {
*/
function testLinkRenderArrayText() {
// Build a link with _l() for reference.
$l = _l('foo', 'http://drupal.org');
$l = \Drupal::l('foo', Url::fromUri('http://drupal.org'));
// Test a renderable array passed to _l().
$renderable_text = array('#markup' => 'foo');
$l_renderable_text = _l($renderable_text, 'http://drupal.org');
$l_renderable_text = \Drupal::l($renderable_text, Url::fromUri('http://drupal.org'));
$this->assertEqual($l_renderable_text, $l);
// Test a themed link with plain text 'text'.

View File

@ -12,6 +12,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\State\StateInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@ -111,7 +112,7 @@ class UpdateManagerUpdate extends FormBase {
// The project name to display can vary based on the info we have.
if (!empty($project['title'])) {
if (!empty($project['link'])) {
$project_name = _l($project['title'], $project['link']);
$project_name = $this->l($project['title'], Url::fromUri($project['link']));
}
else {
$project_name = String::checkPlain($project['title']);
@ -134,7 +135,7 @@ class UpdateManagerUpdate extends FormBase {
}
$recommended_release = $project['releases'][$project['recommended']];
$recommended_version = $recommended_release['version'] . ' ' . _l($this->t('(Release notes)'), $recommended_release['release_link'], array('attributes' => array('title' => $this->t('Release notes for @project_title', array('@project_title' => $project['title'])))));
$recommended_version = $recommended_release['version'] . ' ' . $this->l($this->t('(Release notes)'), Url::fromUri($recommended_release['release_link'], array('attributes' => array('title' => $this->t('Release notes for @project_title', array('@project_title' => $project['title']))))));
if ($recommended_release['version_major'] != $project['existing_major']) {
$recommended_version .= '<div title="Major upgrade warning" class="update-major-version-warning">' . $this->t('This update is a major version update which means that it may not be backwards compatible with your currently running version. It is recommended that you read the release notes and proceed at your own risk.') . '</div>';
}

View File

@ -7,6 +7,7 @@
namespace Drupal\update\Tests;
use Drupal\Core\Url;
use Drupal\Core\Utility\ProjectInfo;
/**
@ -50,12 +51,12 @@ class UpdateContribTest extends UpdateTestBase {
// Cannot use $this->standardTests() because we need to check for the
// 'No available releases found' string.
$this->assertRaw('<h3>' . t('Drupal core') . '</h3>');
$this->assertRaw(_l(t('Drupal'), 'http://example.com/project/drupal'));
$this->assertRaw(\Drupal::l(t('Drupal'), Url::fromUri('http://example.com/project/drupal')));
$this->assertText(t('Up to date'));
$this->assertRaw('<h3>' . t('Modules') . '</h3>');
$this->assertNoText(t('Update available'));
$this->assertText(t('No available releases found'));
$this->assertNoRaw(_l(t('AAA Update test'), 'http://example.com/project/aaa_update_test'));
$this->assertNoRaw(\Drupal::l(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test')));
$available = update_get_available();
$this->assertFalse(isset($available['aaa_update_test']['fetch_status']), 'Results are cached even if no releases are available.');
@ -86,7 +87,7 @@ class UpdateContribTest extends UpdateTestBase {
$this->assertText(t('Up to date'));
$this->assertRaw('<h3>' . t('Modules') . '</h3>');
$this->assertNoText(t('Update available'));
$this->assertRaw(_l(t('AAA Update test'), 'http://example.com/project/aaa_update_test'), 'Link to aaa_update_test project appears.');
$this->assertRaw(\Drupal::l(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test')), 'Link to aaa_update_test project appears.');
}
/**
@ -147,10 +148,10 @@ class UpdateContribTest extends UpdateTestBase {
$this->assertText(t('CCC Update test'));
// We want aaa_update_test included in the ccc_update_test project, not as
// its own project on the report.
$this->assertNoRaw(_l(t('AAA Update test'), 'http://example.com/project/aaa_update_test'), 'Link to aaa_update_test project does not appear.');
$this->assertNoRaw(\Drupal::l(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test')), 'Link to aaa_update_test project does not appear.');
// The other two should be listed as projects.
$this->assertRaw(_l(t('BBB Update test'), 'http://example.com/project/bbb_update_test'), 'Link to bbb_update_test project appears.');
$this->assertRaw(_l(t('CCC Update test'), 'http://example.com/project/ccc_update_test'), 'Link to bbb_update_test project appears.');
$this->assertRaw(\Drupal::l(t('BBB Update test'), Url::fromUri('http://example.com/project/bbb_update_test')), 'Link to bbb_update_test project appears.');
$this->assertRaw(\Drupal::l(t('CCC Update test'), Url::fromUri('http://example.com/project/ccc_update_test')), 'Link to bbb_update_test project appears.');
// We want to make sure we see the BBB project before the CCC project.
// Instead of just searching for 'BBB Update test' or something, we want
@ -197,7 +198,7 @@ class UpdateContribTest extends UpdateTestBase {
);
$this->refreshUpdateStatus($xml_mapping);
$this->assertText(t('Security update required!'));
$this->assertRaw(_l(t('Update test base theme'), 'http://example.com/project/update_test_basetheme'), 'Link to the Update test base theme project appears.');
$this->assertRaw(\Drupal::l(t('Update test base theme'), Url::fromUri('http://example.com/project/update_test_basetheme')), 'Link to the Update test base theme project appears.');
}
/**
@ -247,8 +248,8 @@ class UpdateContribTest extends UpdateTestBase {
'update_test_subtheme' => '1_0',
'update_test_basetheme' => '1_1-sec',
);
$base_theme_project_link = _l(t('Update test base theme'), 'http://example.com/project/update_test_basetheme');
$sub_theme_project_link = _l(t('Update test subtheme'), 'http://example.com/project/update_test_subtheme');
$base_theme_project_link = \Drupal::l(t('Update test base theme'), Url::fromUri('http://example.com/project/update_test_basetheme'));
$sub_theme_project_link = \Drupal::l(t('Update test subtheme'), Url::fromUri('http://example.com/project/update_test_subtheme'));
foreach (array(TRUE, FALSE) as $check_disabled) {
$update_settings->set('check.disabled_extensions', $check_disabled)->save();
$this->refreshUpdateStatus($xml_mapping);
@ -350,9 +351,9 @@ class UpdateContribTest extends UpdateTestBase {
$this->assertUniqueText(t('Failed to get available update data for one project.'));
// The other two should be listed as projects.
$this->assertRaw(_l(t('AAA Update test'), 'http://example.com/project/aaa_update_test'), 'Link to aaa_update_test project appears.');
$this->assertNoRaw(_l(t('BBB Update test'), 'http://example.com/project/bbb_update_test'), 'Link to bbb_update_test project does not appear.');
$this->assertRaw(_l(t('CCC Update test'), 'http://example.com/project/ccc_update_test'), 'Link to bbb_update_test project appears.');
$this->assertRaw(\Drupal::l(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test')), 'Link to aaa_update_test project appears.');
$this->assertNoRaw(\Drupal::l(t('BBB Update test'), Url::fromUri('http://example.com/project/bbb_update_test')), 'Link to bbb_update_test project does not appear.');
$this->assertRaw(\Drupal::l(t('CCC Update test'), Url::fromUri('http://example.com/project/ccc_update_test')), 'Link to bbb_update_test project appears.');
}
/**
@ -394,7 +395,7 @@ class UpdateContribTest extends UpdateTestBase {
$this->drupalGet('admin/reports/updates');
$this->assertRaw('<h3>' . t('Modules') . '</h3>');
$this->assertText(t('Security update required!'));
$this->assertRaw(_l(t('AAA Update test'), 'http://example.com/project/aaa_update_test'), 'Link to aaa_update_test project appears.');
$this->assertRaw(\Drupal::l(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test')), 'Link to aaa_update_test project appears.');
// Visit the reports page again without the altering and make sure the
// status is back to normal.
@ -402,7 +403,7 @@ class UpdateContribTest extends UpdateTestBase {
$this->drupalGet('admin/reports/updates');
$this->assertRaw('<h3>' . t('Modules') . '</h3>');
$this->assertNoText(t('Security update required!'));
$this->assertRaw(_l(t('AAA Update test'), 'http://example.com/project/aaa_update_test'), 'Link to aaa_update_test project appears.');
$this->assertRaw(\Drupal::l(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test')), 'Link to aaa_update_test project appears.');
// Turn the altering back on and visit the Update manager UI.
$update_test_config->set('update_status', $update_status)->save();

View File

@ -7,6 +7,8 @@
namespace Drupal\update\Tests;
use Drupal\Core\Url;
/**
* Tests the Update Manager module through a series of functional tests using
* mock XML data.
@ -72,9 +74,9 @@ class UpdateCoreTest extends UpdateTestBase {
$this->standardTests();
$this->drupalGet('admin/reports/updates/check');
$this->assertNoText(t('Security update required!'));
$this->assertRaw(_l("8.$minor_version.1" . $extra_version, "http://example.com/drupal-8-$minor_version-1$extra_version-release"), 'Link to release appears.');
$this->assertRaw(_l(t('Download'), "http://example.com/drupal-8-$minor_version-1$extra_version.tar.gz"), 'Link to download appears.');
$this->assertRaw(_l(t('Release notes'), "http://example.com/drupal-8-$minor_version-1$extra_version-release"), 'Link to release notes appears.');
$this->assertRaw(\Drupal::l("8.$minor_version.1" . $extra_version, Url::fromUri("http://example.com/drupal-8-$minor_version-1$extra_version-release")), 'Link to release appears.');
$this->assertRaw(\Drupal::l(t('Download'), Url::fromUri("http://example.com/drupal-8-$minor_version-1$extra_version.tar.gz")), 'Link to download appears.');
$this->assertRaw(\Drupal::l(t('Release notes'), Url::fromUri("http://example.com/drupal-8-$minor_version-1$extra_version-release")), 'Link to release notes appears.');
switch ($minor_version) {
case 0:
@ -130,9 +132,9 @@ class UpdateCoreTest extends UpdateTestBase {
$this->standardTests();
$this->drupalGet('admin/reports/updates/check');
$this->assertNoText(t('Security update required!'));
$this->assertRaw(_l('9.0.0', "http://example.com/drupal-9-0-0-release"), 'Link to release appears.');
$this->assertRaw(_l(t('Download'), "http://example.com/drupal-9-0-0.tar.gz"), 'Link to download appears.');
$this->assertRaw(_l(t('Release notes'), "http://example.com/drupal-9-0-0-release"), 'Link to release notes appears.');
$this->assertRaw(\Drupal::l('9.0.0', Url::fromUri("http://example.com/drupal-9-0-0-release")), 'Link to release appears.');
$this->assertRaw(\Drupal::l(t('Download'), Url::fromUri("http://example.com/drupal-9-0-0.tar.gz")), 'Link to download appears.');
$this->assertRaw(\Drupal::l(t('Release notes'), Url::fromUri("http://example.com/drupal-9-0-0-release")), 'Link to release notes appears.');
$this->assertNoText(t('Up to date'));
$this->assertText(t('Not supported!'));
$this->assertText(t('Recommended version:'));
@ -153,9 +155,9 @@ class UpdateCoreTest extends UpdateTestBase {
$this->assertNoText(t('Up to date'));
$this->assertNoText(t('Update available'));
$this->assertText(t('Security update required!'));
$this->assertRaw(_l("8.$minor_version.2", "http://example.com/drupal-8-$minor_version-2-release"), 'Link to release appears.');
$this->assertRaw(_l(t('Download'), "http://example.com/drupal-8-$minor_version-2.tar.gz"), 'Link to download appears.');
$this->assertRaw(_l(t('Release notes'), "http://example.com/drupal-8-$minor_version-2-release"), 'Link to release notes appears.');
$this->assertRaw(\Drupal::l("8.$minor_version.2", Url::fromUri("http://example.com/drupal-8-$minor_version-2-release")), 'Link to release appears.');
$this->assertRaw(\Drupal::l(t('Download'), Url::fromUri("http://example.com/drupal-8-$minor_version-2.tar.gz")), 'Link to download appears.');
$this->assertRaw(\Drupal::l(t('Release notes'), Url::fromUri("http://example.com/drupal-8-$minor_version-2-release")), 'Link to release notes appears.');
}
}

View File

@ -21,6 +21,7 @@
namespace Drupal\update\Tests;
use Drupal\Core\Url;
use Drupal\simpletest\WebTestBase;
/**
@ -55,7 +56,7 @@ abstract class UpdateTestBase extends WebTestBase {
*/
protected function standardTests() {
$this->assertRaw('<h3>' . t('Drupal core') . '</h3>');
$this->assertRaw(_l(t('Drupal'), 'http://example.com/project/drupal'), 'Link to the Drupal project appears.');
$this->assertRaw(\Drupal::l(t('Drupal'), Url::fromUri('http://example.com/project/drupal')), 'Link to the Drupal project appears.');
$this->assertNoText(t('No available releases found'));
}
}

View File

@ -28,8 +28,7 @@ class LinkEdit extends Link {
$text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Edit');
$this->options['alter']['path'] = $entity->getSystemPath('edit-form');
$this->options['alter']['query'] = drupal_get_destination();
$this->options['alter']['url'] = $entity->urlInfo('edit-form', ['query' => ['destination' => drupal_get_destination()]]);
return $text;
}

View File

@ -52,9 +52,7 @@ class UserAdminTest extends WebTestBase {
$this->assertText($admin_user->getUsername(), 'Found Admin user on admin users page');
// Test for existence of edit link in table.
// @todo This cannot be converted to \Drupal::l() until
// https://www.drupal.org/node/2345725 is resolved.
$link = _l(t('Edit'), "user/" . $user_a->id() . "/edit", array('query' => array('destination' => 'admin/people')));
$link = $user_a->link(t('Edit'), 'edit-form', array('query' => array('destination' => 'admin/people')));
$this->assertRaw($link, 'Found user A edit link on admin users page');
// Test exposed filter elements.

View File

@ -87,6 +87,13 @@ abstract class FieldPluginBase extends HandlerBase {
*/
var $additional_fields = array();
/**
* The link generator.
*
* @var \Drupal\Core\Utility\LinkGeneratorInterface
*/
protected $linkGenerator;
/**
* Overrides Drupal\views\Plugin\views\HandlerBase::init().
*/
@ -1345,6 +1352,10 @@ abstract class FieldPluginBase extends HandlerBase {
'absolute' => !empty($alter['absolute']) ? TRUE : FALSE,
);
$alter += [
'path' => NULL
];
// $path will be run through check_url() by _l() so we do not need to
// sanitize it ourselves.
$path = $alter['path'];
@ -1376,7 +1387,7 @@ abstract class FieldPluginBase extends HandlerBase {
// If the path is empty do not build a link around the given text and return
// it as is.
// http://www.example.com URLs will not have a $url['path'], so check host as well.
if (empty($url['path']) && empty($url['host']) && empty($url['fragment'])) {
if (empty($url['path']) && empty($url['host']) && empty($url['fragment']) && empty($url['url'])) {
return $text;
}
@ -1483,7 +1494,12 @@ abstract class FieldPluginBase extends HandlerBase {
$options['entity_type'] = $alter['entity_type'];
}
$value .= _l($text, $path, $options);
if (isset($options['url']) && $options['url'] instanceof Url) {
$value .= $this->linkGenerator()->generate($text, $options['url']);
}
else {
$value .= _l($text, $path, $options);
}
if (!empty($alter['suffix'])) {
$value .= Xss::filterAdmin(strtr($alter['suffix'], $tokens));
@ -1718,6 +1734,17 @@ abstract class FieldPluginBase extends HandlerBase {
return $value;
}
/**
* Gets the link generator.
*
* @return \Drupal\Core\Utility\LinkGeneratorInterface
*/
protected function linkGenerator() {
if (!isset($this->linkGenerator)) {
$this->linkGenerator = \Drupal::linkGenerator();
}
return $this->linkGenerator;
}
}
/**

View File

@ -73,15 +73,19 @@ abstract class Links extends FieldPluginBase {
}
$title = $this->view->field[$field]->last_render_text;
$path = '';
$url = NULL;
if (!empty($this->view->field[$field]->options['alter']['path'])) {
$path = $this->view->field[$field]->options['alter']['path'];
}
elseif (!empty($this->view->field[$field]->options['alter']['url']) && $this->view->field[$field]->options['alter']['url'] instanceof UrlObject) {
$url = $this->view->field[$field]->options['alter']['url'];
}
// Make sure that tokens are replaced for this paths as well.
$tokens = $this->getRenderTokens(array());
$path = strip_tags(String::decodeEntities(strtr($path, $tokens)));
$links[$field] = array(
'url' => UrlObject::fromUri('base://' . $path),
'url' => $path ? UrlObject::fromUri('base://' . $path) : $url,
'title' => $title,
);
if (!empty($this->options['destination'])) {

View File

@ -7,6 +7,7 @@
namespace Drupal\views\Tests\Handler;
use Drupal\Core\Url;
use Drupal\views\Tests\ViewUnitTestBase;
use Drupal\views\Views;
@ -70,7 +71,7 @@ class FieldUrlTest extends ViewUnitTestBase {
$this->executeView($view);
$this->assertEqual(_l('John', 'John'), $view->field['name']->advancedRender($view->result[0]));
$this->assertEqual(\Drupal::l('John', Url::fromUri('base://John')), $view->field['name']->advancedRender($view->result[0]));
}
}

View File

@ -8,6 +8,7 @@
namespace Drupal\views_ui\Form\Ajax;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\views\ViewStorageInterface;
use Drupal\views\ViewExecutable;
@ -124,7 +125,7 @@ class Rearrange extends ViewsFormBase {
'#id' => 'views-removed-' . $id,
'#attributes' => array('class' => array('views-remove-checkbox')),
'#default_value' => 0,
'#suffix' => _l('<span>' . $this->t('Remove') . '</span>', 'javascript:void()', array('attributes' => array('id' => 'views-remove-link-' . $id, 'class' => array('views-hidden', 'views-button-remove', 'views-remove-link'), 'alt' => $this->t('Remove this item'), 'title' => $this->t('Remove this item')), 'html' => TRUE)),
'#suffix' => \Drupal::l('<span>' . $this->t('Remove') . '</span>', Url::fromRoute('<none>', array('attributes' => array('id' => 'views-remove-link-' . $id, 'class' => array('views-hidden', 'views-button-remove', 'views-remove-link'), 'alt' => $this->t('Remove this item'), 'title' => $this->t('Remove this item')), 'html' => TRUE))),
);
}

View File

@ -14,6 +14,7 @@ use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@ -263,7 +264,7 @@ class ViewListBuilder extends ConfigEntityListBuilder {
if ($display->hasPath()) {
$path = $display->getPath();
if ($view->status() && strpos($path, '%') === FALSE) {
$all_paths[] = _l('/' . $path, $path);
$all_paths[] = \Drupal::l('/' . $path, Url::fromUri('base://' . $path));
}
else {
$all_paths[] = String::checkPlain('/' . $path);

View File

@ -12,6 +12,7 @@ use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Timer;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\views\Views;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\views\ViewExecutable;
@ -693,7 +694,7 @@ class ViewUI implements ViewStorageInterface {
Xss::filterAdmin($this->executable->getTitle()),
);
if (isset($path)) {
$path = _l($path, $path);
$path = \Drupal::l($path, Url::fromUri('base://' . $path));
}
else {
$path = t('This display has no path.');

View File

@ -158,7 +158,7 @@ function theme_views_ui_build_group_filter_form($variables) {
'value' => drupal_render($form['group_items'][$group_id]['value']),
'remove' => array(
'data' => array(
'#markup' => drupal_render($form['group_items'][$group_id]['remove']) . _l('<span>' . t('Remove') . '</span>', 'javascript:void()', array('attributes' => array('id' => 'views-remove-link-' . $group_id, 'class' => array('views-hidden', 'views-button-remove', 'views-groups-remove-link', 'views-remove-link'), 'alt' => t('Remove this item'), 'title' => t('Remove this item')), 'html' => true)),
'#markup' => drupal_render($form['group_items'][$group_id]['remove']) . \Drupal::l('<span>' . t('Remove') . '</span>', Url::fromRoute('<none>', array('attributes' => array('id' => 'views-remove-link-' . $group_id, 'class' => array('views-hidden', 'views-button-remove', 'views-groups-remove-link', 'views-remove-link'), 'alt' => t('Remove this item'), 'title' => t('Remove this item')), 'html' => true))),
),
),
);