Commit 7b5e5a95 authored by alexpott's avatar alexpott

Issue #2404603 by mpdonadio, dawehner, larowlan, RavindraSingh: Add proper...

Issue #2404603 by mpdonadio, dawehner, larowlan, RavindraSingh: Add proper support for Url objects in FieldPluginBase::renderAsLink(), so we can remove EntityInterface::getSystemPath()
parent 203ead62
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Drupal\aggregator\Plugin\views\field; namespace Drupal\aggregator\Plugin\views\field;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
...@@ -78,7 +79,8 @@ protected function renderLink($data, ResultRow $values) { ...@@ -78,7 +79,8 @@ protected function renderLink($data, ResultRow $values) {
$link = $this->getValue($values, 'link'); $link = $this->getValue($values, 'link');
if (!empty($this->options['display_as_link'])) { if (!empty($this->options['display_as_link'])) {
$this->options['alter']['make_link'] = TRUE; $this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = $link; // Note: $link is an external URI, pointing to the feed itself.
$this->options['alter']['url'] = Url::fromUri($link);
$this->options['alter']['html'] = TRUE; $this->options['alter']['html'] = TRUE;
$this->options['alter']['absolute'] = TRUE; $this->options['alter']['absolute'] = TRUE;
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Drupal\comment\Plugin\views\field; namespace Drupal\comment\Plugin\views\field;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase;
...@@ -92,7 +93,7 @@ protected function renderLink($data, ResultRow $values) { ...@@ -92,7 +93,7 @@ protected function renderLink($data, ResultRow $values) {
$this->options['alter']['make_link'] = TRUE; $this->options['alter']['make_link'] = TRUE;
$cid = $this->getValue($values, 'cid'); $cid = $this->getValue($values, 'cid');
if (!empty($cid)) { if (!empty($cid)) {
$this->options['alter']['path'] = "comment/" . $cid; $this->options['alter']['url'] = Url::fromRoute('entity.comment.canonical', ['comment' => $cid]);
$this->options['alter']['fragment'] = "comment-" . $cid; $this->options['alter']['fragment'] = "comment-" . $cid;
} }
// If there is no comment link to the entity. // If there is no comment link to the entity.
...@@ -100,7 +101,7 @@ protected function renderLink($data, ResultRow $values) { ...@@ -100,7 +101,7 @@ protected function renderLink($data, ResultRow $values) {
$entity_id = $this->getValue($values, 'entity_id'); $entity_id = $this->getValue($values, 'entity_id');
$entity_type = $this->getValue($values, 'entity_type'); $entity_type = $this->getValue($values, 'entity_type');
$entity = entity_load($entity_type, $entity_id); $entity = entity_load($entity_type, $entity_id);
$this->options['alter']['path'] = $entity->getSystemPath(); $this->options['alter']['url'] = $entity->urlInfo();
} }
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Url;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
...@@ -111,13 +112,13 @@ protected function renderLink($data, ResultRow $values) { ...@@ -111,13 +112,13 @@ protected function renderLink($data, ResultRow $values) {
$this->options['alter']['html'] = TRUE; $this->options['alter']['html'] = TRUE;
if (!empty($cid)) { if (!empty($cid)) {
$this->options['alter']['path'] = "comment/" . $cid; $this->options['alter']['url'] = Url::fromRoute('entity.comment.canonical', ['comment' => $cid]);
$this->options['alter']['fragment'] = "comment-" . $cid; $this->options['alter']['fragment'] = "comment-" . $cid;
} }
// If there is no comment link to the node. // If there is no comment link to the node.
elseif ($this->options['link_to_node']) { elseif ($this->options['link_to_node']) {
$entity = $comment->getCommentedEntity(); $entity = $comment->getCommentedEntity();
$this->options['alter']['path'] = $entity->getSystemPath(); $this->options['alter']['url'] = $entity->urlInfo();
} }
return $text; return $text;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
use Drupal\comment\CommentInterface; use Drupal\comment\CommentInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
/** /**
...@@ -51,8 +52,8 @@ protected function renderLink($data, ResultRow $values) { ...@@ -51,8 +52,8 @@ protected function renderLink($data, ResultRow $values) {
$comment = $this->get_entity($values); $comment = $this->get_entity($values);
$this->options['alter']['make_link'] = TRUE; $this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = "comment/" . $comment->id() . "/approve"; $this->options['alter']['url'] = Url::fromRoute('comment.approve', ['comment' => $comment->id()]);
$this->options['alter']['query'] = drupal_get_destination() + array('token' => \Drupal::csrfToken()->get($this->options['alter']['path'])); $this->options['alter']['query'] = drupal_get_destination() + array('token' => \Drupal::csrfToken()->get($this->options['alter']['url']->toString()));
return $text; return $text;
} }
......
...@@ -43,7 +43,7 @@ protected function renderLink($data, ResultRow $values) { ...@@ -43,7 +43,7 @@ protected function renderLink($data, ResultRow $values) {
$comment = $this->getEntity($values); $comment = $this->getEntity($values);
$this->options['alter']['make_link'] = TRUE; $this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = $comment->getSystemPath('delete-form'); $this->options['alter']['url'] = $comment->urlInfo('delete-form');
$this->options['alter']['query'] = drupal_get_destination(); $this->options['alter']['query'] = drupal_get_destination();
return $text; return $text;
......
...@@ -63,7 +63,7 @@ protected function renderLink($data, ResultRow $values) { ...@@ -63,7 +63,7 @@ protected function renderLink($data, ResultRow $values) {
$this->options['alter']['query'] = drupal_get_destination(); $this->options['alter']['query'] = drupal_get_destination();
} }
$this->options['alter']['path'] = "comment/" . $comment->id() . "/edit"; $this->options['alter']['url'] = $comment->urlInfo('edit-form');
return $text; return $text;
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Drupal\comment\Plugin\views\field; namespace Drupal\comment\Plugin\views\field;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
/** /**
...@@ -43,8 +44,12 @@ protected function renderLink($data, ResultRow $values) { ...@@ -43,8 +44,12 @@ protected function renderLink($data, ResultRow $values) {
$comment = $this->getEntity($values); $comment = $this->getEntity($values);
$this->options['alter']['make_link'] = TRUE; $this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = "comment/reply/{$comment->getCommentedEntityTypeId()}/{$comment->getCommentedEntityId()}/{$comment->getFieldName()}/{$comment->id()}"; $this->options['alter']['url'] = Url::fromRoute('comment.reply', [
'entity_type' => $comment->getCommentedEntityTypeId(),
'entity' => $comment->getCommentedEntityId(),
'field_name' => $comment->getFieldName(),
'pid' => $comment->id(),
]);
return $text; return $text;
} }
......
...@@ -167,7 +167,7 @@ protected function renderLink($data, ResultRow $values) { ...@@ -167,7 +167,7 @@ protected function renderLink($data, ResultRow $values) {
$page_number = \Drupal::entityManager()->getStorage('comment') $page_number = \Drupal::entityManager()->getStorage('comment')
->getNewCommentPageNumber($this->getValue($values, 'comment_count'), $this->getValue($values), $node); ->getNewCommentPageNumber($this->getValue($values, 'comment_count'), $this->getValue($values), $node);
$this->options['alter']['make_link'] = TRUE; $this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = 'node/' . $node->id(); $this->options['alter']['url'] = $node->urlInfo();
$this->options['alter']['query'] = $page_number ? array('page' => $page_number) : NULL; $this->options['alter']['query'] = $page_number ? array('page' => $page_number) : NULL;
$this->options['alter']['fragment'] = 'new'; $this->options['alter']['fragment'] = 'new';
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\user\Plugin\views\field\Link; use Drupal\user\Plugin\views\field\Link;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
...@@ -117,7 +118,7 @@ protected function renderLink(EntityInterface $entity, ResultRow $values) { ...@@ -117,7 +118,7 @@ protected function renderLink(EntityInterface $entity, ResultRow $values) {
} }
$this->options['alter']['make_link'] = TRUE; $this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = "user/{$entity->id()}/contact"; $this->options['alter']['url'] = Url::fromRoute('entity.user.contact_form', ['user' => $entity->id()]);
$title = $this->t('Contact %user', array('%user' => $entity->name->value)); $title = $this->t('Contact %user', array('%user' => $entity->name->value));
$this->options['alter']['attributes'] = array('title' => $title); $this->options['alter']['attributes'] = array('title' => $title);
......
...@@ -65,7 +65,7 @@ protected function renderLink(EntityInterface $entity, ResultRow $values) { ...@@ -65,7 +65,7 @@ protected function renderLink(EntityInterface $entity, ResultRow $values) {
$text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Translate'); $text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Translate');
$this->options['alter']['make_link'] = TRUE; $this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = $entity->getSystemPath('drupal:content-translation-overview'); $this->options['alter']['url'] = $entity->urlInfo('drupal:content-translation-overview');
return $text; return $text;
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
use Drupal\Component\Utility\String; use Drupal\Component\Utility\String;
use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
...@@ -96,6 +97,9 @@ public function render(ResultRow $values) { ...@@ -96,6 +97,9 @@ public function render(ResultRow $values) {
if (!empty($this->view->field[$field]->options['alter']['path'])) { if (!empty($this->view->field[$field]->options['alter']['path'])) {
$path = $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 Url) {
$path = $this->view->field[$field]->options['alter']['url']->toString();
}
if (!empty($title) && !empty($path)) { if (!empty($title) && !empty($path)) {
// Make sure that tokens are replaced for this paths as well. // Make sure that tokens are replaced for this paths as well.
$tokens = $this->getRenderTokens(array()); $tokens = $this->getRenderTokens(array());
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Drupal\file\Plugin\views\field; namespace Drupal\file\Plugin\views\field;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase;
......
...@@ -76,7 +76,7 @@ public function render(ResultRow $values) { ...@@ -76,7 +76,7 @@ public function render(ResultRow $values) {
protected function renderLink($node, ResultRow $values) { protected function renderLink($node, ResultRow $values) {
if ($node->access('view')) { if ($node->access('view')) {
$this->options['alter']['make_link'] = TRUE; $this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = 'node/' . $node->id(); $this->options['alter']['url'] = $node->urlInfo();
$text = !empty($this->options['text']) ? $this->options['text'] : $this->t('View'); $text = !empty($this->options['text']) ? $this->options['text'] : $this->t('View');
return $text; return $text;
} }
......
...@@ -37,7 +37,7 @@ protected function renderLink($node, ResultRow $values) { ...@@ -37,7 +37,7 @@ protected function renderLink($node, ResultRow $values) {
} }
$this->options['alter']['make_link'] = TRUE; $this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = $node->getSystemPath('delete-form'); $this->options['alter']['url'] = $node->urlInfo('delete-form');
$this->options['alter']['query'] = drupal_get_destination(); $this->options['alter']['query'] = drupal_get_destination();
$text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Delete'); $text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Delete');
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
namespace Drupal\node\Plugin\views\field; namespace Drupal\node\Plugin\views\field;
use Drupal\Core\Url;
use Drupal\node\Plugin\views\field\Link; use Drupal\node\Plugin\views\field\Link;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
...@@ -37,7 +38,7 @@ protected function renderLink($node, ResultRow $values) { ...@@ -37,7 +38,7 @@ protected function renderLink($node, ResultRow $values) {
} }
$this->options['alter']['make_link'] = TRUE; $this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = "node/" . $node->id() . "/edit"; $this->options['alter']['url'] = $node->urlInfo('edit-form');
$this->options['alter']['query'] = drupal_get_destination(); $this->options['alter']['query'] = drupal_get_destination();
$text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Edit'); $text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Edit');
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Drupal\node\Plugin\views\field; namespace Drupal\node\Plugin\views\field;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase;
...@@ -71,7 +72,7 @@ protected function renderLink($data, ResultRow $values) { ...@@ -71,7 +72,7 @@ protected function renderLink($data, ResultRow $values) {
if (!empty($this->options['link_to_node']) && !empty($this->additional_fields['nid'])) { if (!empty($this->options['link_to_node']) && !empty($this->additional_fields['nid'])) {
if ($data !== NULL && $data !== '') { if ($data !== NULL && $data !== '') {
$this->options['alter']['make_link'] = TRUE; $this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = "node/" . $this->getValue($values, 'nid'); $this->options['alter']['url'] = Url::fromRoute('entity.node.canonical', ['node' => $this->getValue($values, 'nid')]);
if (isset($this->aliases['langcode'])) { if (isset($this->aliases['langcode'])) {
$languages = \Drupal::languageManager()->getLanguages(); $languages = \Drupal::languageManager()->getLanguages();
$langcode = $this->getValue($values, 'langcode'); $langcode = $this->getValue($values, 'langcode');
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Drupal\node\Plugin\views\field; namespace Drupal\node\Plugin\views\field;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase;
...@@ -68,7 +69,7 @@ protected function renderLink($data, ResultRow $values) { ...@@ -68,7 +69,7 @@ protected function renderLink($data, ResultRow $values) {
$this->options['alter']['make_link'] = TRUE; $this->options['alter']['make_link'] = TRUE;
$nid = $this->getValue($values, 'nid'); $nid = $this->getValue($values, 'nid');
$vid = $this->getValue($values, 'vid'); $vid = $this->getValue($values, 'vid');
$this->options['alter']['path'] = "node/" . $nid . '/revisions/' . $vid . '/view'; $this->options['alter']['url'] = Url::fromRoute('node.revision_show', ['node' => $nid, 'node_revision' => $vid]);
} }
else { else {
return parent::renderLink($data, $values); return parent::renderLink($data, $values);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Drupal\node\Plugin\views\field; namespace Drupal\node\Plugin\views\field;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\node\Plugin\views\field\Link; use Drupal\node\Plugin\views\field\Link;
use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
...@@ -56,13 +57,15 @@ protected function renderLink($data, ResultRow $values) { ...@@ -56,13 +57,15 @@ protected function renderLink($data, ResultRow $values) {
} }
// Current revision uses the node view path. // Current revision uses the node view path.
$path = 'node/' . $node->nid;
if (!$node->isDefaultRevision()) { if (!$node->isDefaultRevision()) {
$path .= "/revisions/$vid/view"; $url = Url::fromRoute('node.revision_show', ['node' => $node->nid, 'node_revision' => $vid]);
}
else {
$url = $node->urlInfo();
} }
$this->options['alter']['make_link'] = TRUE; $this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = $path; $this->options['alter']['url'] = $url;
$this->options['alter']['query'] = drupal_get_destination(); $this->options['alter']['query'] = drupal_get_destination();
return !empty($this->options['text']) ? $this->options['text'] : $this->t('View'); return !empty($this->options['text']) ? $this->options['text'] : $this->t('View');
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Drupal\node\Plugin\views\field; namespace Drupal\node\Plugin\views\field;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\node\Plugin\views\field\RevisionLink; use Drupal\node\Plugin\views\field\RevisionLink;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
...@@ -50,7 +51,7 @@ protected function renderLink($data, ResultRow $values) { ...@@ -50,7 +51,7 @@ protected function renderLink($data, ResultRow $values) {
} }
$this->options['alter']['make_link'] = TRUE; $this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = 'node/' . $node->id() . "/revisions/$vid/delete"; $this->options['alter']['url'] = Url::fromRoute('node.revision_delete_confirm', ['node' => $node->id(), 'node_revision' => $vid]);
$this->options['alter']['query'] = drupal_get_destination(); $this->options['alter']['query'] = drupal_get_destination();
return !empty($this->options['text']) ? $this->options['text'] : $this->t('Delete'); return !empty($this->options['text']) ? $this->options['text'] : $this->t('Delete');
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Drupal\node\Plugin\views\field; namespace Drupal\node\Plugin\views\field;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\node\Plugin\views\field\RevisionLink; use Drupal\node\Plugin\views\field\RevisionLink;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
...@@ -50,7 +51,7 @@ protected function renderLink($data, ResultRow $values) { ...@@ -50,7 +51,7 @@ protected function renderLink($data, ResultRow $values) {
} }
$this->options['alter']['make_link'] = TRUE; $this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = 'node/' . $node->id() . "/revisions/$vid/revert"; $this->options['alter']['url'] = Url::fromRoute('node.revision_revert_confirm', ['node' => $node->id(), 'node_revision' => $vid]);
$this->options['alter']['query'] = drupal_get_destination(); $this->options['alter']['query'] = drupal_get_destination();
return !empty($this->options['text']) ? $this->options['text'] : $this->t('Revert'); return !empty($this->options['text']) ? $this->options['text'] : $this->t('Revert');
......
...@@ -81,7 +81,7 @@ protected function renderLink($data, ResultRow $values) { ...@@ -81,7 +81,7 @@ protected function renderLink($data, ResultRow $values) {
if (!empty($this->options['link_to_taxonomy']) && $term && $data !== NULL && $data !== '') { if (!empty($this->options['link_to_taxonomy']) && $term && $data !== NULL && $data !== '') {
$this->options['alter']['make_link'] = TRUE; $this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = $term->getSystemPath(); $this->options['alter']['url'] = $term->urlInfo();
} }
if (!empty($this->options['convert_spaces'])) { if (!empty($this->options['convert_spaces'])) {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
namespace Drupal\user\Plugin\views\field; namespace Drupal\user\Plugin\views\field;
use Drupal\Core\Url;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
/** /**
...@@ -26,7 +27,7 @@ protected function renderLink($data, ResultRow $values) { ...@@ -26,7 +27,7 @@ protected function renderLink($data, ResultRow $values) {
$uid = $this->getValue($values, 'uid'); $uid = $this->getValue($values, 'uid');
if ($this->view->getUser()->hasPermission('access user profiles') && $uid) { if ($this->view->getUser()->hasPermission('access user profiles') && $uid) {
$this->options['alter']['make_link'] = TRUE; $this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = 'user/' . $uid; $this->options['alter']['url'] = Url::fromRoute('entity.user.canonical', ['user' => $uid]);
} }
} }
if (empty($data)) { if (empty($data)) {
......
...@@ -90,7 +90,7 @@ protected function renderLink(EntityInterface $entity, ResultRow $values) { ...@@ -90,7 +90,7 @@ protected function renderLink(EntityInterface $entity, ResultRow $values) {
$text = !empty($this->options['text']) ? $this->options['text'] : $this->t('View'); $text = !empty($this->options['text']) ? $this->options['text'] : $this->t('View');
$this->options['alter']['make_link'] = TRUE; $this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = $entity->getSystemPath(); $this->options['alter']['url'] = $entity->urlInfo();
return $text; return $text;
} }
......
...@@ -28,7 +28,7 @@ protected function renderLink(EntityInterface $entity, ResultRow $values) { ...@@ -28,7 +28,7 @@ protected function renderLink(EntityInterface $entity, ResultRow $values) {
$text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Cancel account'); $text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Cancel account');
$this->options['alter']['path'] = $entity->getSystemPath('cancel-form'); $this->options['alter']['url'] = $entity->urlInfo('cancel-form');
$this->options['alter']['query'] = drupal_get_destination(); $this->options['alter']['query'] = drupal_get_destination();
return $text; return $text;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Drupal\user\Plugin\views\field; namespace Drupal\user\Plugin\views\field;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
/** /**
......
...@@ -66,7 +66,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { ...@@ -66,7 +66,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {