Commit 60505f36 authored by alexpott's avatar alexpott

Issue #3019834 by Berdir, alexpott: Add @trigger_error() to deprecated...

Issue #3019834 by Berdir, alexpott: Add @trigger_error() to deprecated url/link EntityInterface methods
parent 8b6fd657
......@@ -2139,7 +2139,7 @@ function hook_mail($key, &$message, $params) {
$node = $params['node'];
$variables += [
'%uid' => $node->getOwnerId(),
'%url' => $node->url('canonical', ['absolute' => TRUE]),
'%url' => $node->toUrl('canonical', ['absolute' => TRUE])->toString(),
'%node_type' => node_get_type_label($node),
'%title' => $node->getTitle(),
'%teaser' => $node->teaser,
......
......@@ -67,7 +67,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$untranslated_entity = $entity->getUntranslated();
$untranslated_entity->removeTranslation($entity->language()->getId());
$untranslated_entity->save();
$form_state->setRedirectUrl($untranslated_entity->urlInfo('canonical'));
$form_state->setRedirectUrl($untranslated_entity->toUrl('canonical'));
}
else {
$entity->delete();
......@@ -84,7 +84,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
public function getCancelUrl() {
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = $this->getEntity();
return $entity->isDefaultTranslation() ? $this->traitGetCancelUrl() : $entity->urlInfo('canonical');
return $entity->isDefaultTranslation() ? $this->traitGetCancelUrl() : $entity->toUrl('canonical');
}
/**
......
......@@ -178,6 +178,7 @@ public function label() {
* {@inheritdoc}
*/
public function urlInfo($rel = 'canonical', array $options = []) {
@trigger_error('EntityInterface::urlInfo() is deprecated in Drupal 8.0.0 and will be removed in Drupal 9.0.0. EntityInterface::toUrl() instead. See https://www.drupal.org/node/2614344', E_USER_DEPRECATED);
return $this->toUrl($rel, $options);
}
......@@ -266,6 +267,7 @@ protected function linkTemplates() {
* {@inheritdoc}
*/
public function link($text = NULL, $rel = 'canonical', array $options = []) {
@trigger_error("EntityInterface::link() is deprecated in Drupal 8.0.0 and will be removed in Drupal 9.0.0. EntityInterface::toLink() instead. Note, the default relationship for configuration entities changes from 'edit-form' to 'canonical'. See https://www.drupal.org/node/2614344", E_USER_DEPRECATED);
return $this->toLink($text, $rel, $options)->toString();
}
......@@ -286,6 +288,7 @@ public function toLink($text = NULL, $rel = 'canonical', array $options = []) {
* {@inheritdoc}
*/
public function url($rel = 'canonical', $options = []) {
@trigger_error('EntityInterface::url() is deprecated in Drupal 8.0.0 and will be removed in Drupal 9.0.0. EntityInterface::toUrl() instead. Note, a \Drupal\Core\Url object is returned. See https://www.drupal.org/node/2614344', E_USER_DEPRECATED);
// While self::toUrl() will throw an exception if the entity has no id,
// the expected result for a URL is always a string.
if ($this->id() === NULL || !$this->hasLinkTemplate($rel)) {
......
......@@ -78,11 +78,11 @@ public function getCancelUrl() {
$entity = $this->getEntity();
if ($entity->hasLinkTemplate('collection')) {
// If available, return the collection URL.
return $entity->urlInfo('collection');
return $entity->toUrl('collection');
}
else {
// Otherwise fall back to the default link template.
return $entity->urlInfo();
return $entity->toUrl();
}
}
......@@ -96,7 +96,7 @@ protected function getRedirectUrl() {
$entity = $this->getEntity();
if ($entity->hasLinkTemplate('collection')) {
// If available, return the collection URL.
return $entity->urlInfo('collection');
return $entity->toUrl('collection');
}
else {
// Otherwise fall back to the front page.
......
......@@ -246,7 +246,7 @@ protected function actions(array $form, FormStateInterface $form_state) {
];
if (!$this->entity->isNew() && $this->entity->hasLinkTemplate('delete-form')) {
$route_info = $this->entity->urlInfo('delete-form');
$route_info = $this->entity->toUrl('delete-form');
if ($this->getRequest()->query->has('destination')) {
$query = $route_info->getOption('query');
$query['destination'] = $this->getRequest()->query->get('destination');
......
......@@ -65,7 +65,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
// link.
if ($output_as_link && !$entity->isNew()) {
try {
$uri = $entity->urlInfo();
$uri = $entity->toUrl();
}
catch (UndefinedLinkTemplateException $e) {
// This exception is thrown by \Drupal\Core\Entity\Entity::urlInfo()
......
......@@ -100,7 +100,7 @@ function hook_tokens($type, $tokens, array $data, array $options, \Drupal\Core\R
break;
case 'edit-url':
$replacements[$original] = $node->url('edit-form', $url_options);
$replacements[$original] = $node->toUrl('edit-form', $url_options)->toString();
break;
// Default values for the chained tokens handled below.
......
......@@ -115,7 +115,7 @@ public function adminOverview() {
/** @var \Drupal\aggregator\FeedInterface[] $feeds */
foreach ($feeds as $feed) {
$row = [];
$row[] = $feed->link();
$row[] = $feed->toLink()->toString();
$row[] = $this->formatPlural($entity_manager->getStorage('aggregator_item')->getItemCount($feed), '1 item', '@count items');
$last_checked = $feed->getLastCheckedTime();
$refresh_rate = $feed->getRefreshRate();
......
......@@ -20,10 +20,10 @@ public function save(array $form, FormStateInterface $form_state) {
$feed = $this->entity;
$status = $feed->save();
$label = $feed->label();
$view_link = $feed->link($label, 'canonical');
$view_link = $feed->toLink($label, 'canonical')->toString();
if ($status == SAVED_UPDATED) {
$this->messenger()->addStatus($this->t('The feed %feed has been updated.', ['%feed' => $view_link]));
$form_state->setRedirectUrl($feed->urlInfo('canonical'));
$form_state->setRedirectUrl($feed->toUrl('canonical'));
}
else {
$this->logger('aggregator')->notice('Feed %feed added.', ['%feed' => $feed->label(), 'link' => $this->l($this->t('View'), new Url('aggregator.admin_overview'))]);
......
......@@ -146,13 +146,13 @@ public function build() {
foreach ($items as $item) {
$build['list']['#items'][$item->id()] = [
'#type' => 'link',
'#url' => $item->urlInfo(),
'#url' => $item->toUrl(),
'#title' => $item->label(),
];
}
$build['more_link'] = [
'#type' => 'more_link',
'#url' => $feed->urlInfo(),
'#url' => $feed->toUrl(),
'#attributes' => ['title' => $this->t("View this feed's recent news.")],
];
return $build;
......
......@@ -60,7 +60,7 @@ public function testBlockLinks() {
$this->assert(isset($links[0]), 'Item link found.');
// Find the expected read_more link.
$href = $feed->url();
$href = $feed->toUrl()->toString();
$links = $this->xpath('//a[@href = :href]', [':href' => $href]);
$this->assert(isset($links[0]), format_string('Link to href %href found.', ['%href' => $href]));
$cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
......@@ -68,7 +68,7 @@ public function testBlockLinks() {
$this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
// Visit that page.
$this->drupalGet($feed->urlInfo()->getInternalPath());
$this->drupalGet($feed->toUrl()->getInternalPath());
$correct_titles = $this->xpath('//h1[normalize-space(text())=:title]', [':title' => $feed->label()]);
$this->assertFalse(empty($correct_titles), 'Aggregator feed page is available and has the correct title.');
$cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags'));
......@@ -112,7 +112,7 @@ public function testFeedPage() {
$this->assertTrue(!empty($titles), 'Source page contains correct title.');
// Find the expected read_more link on the sources page.
$href = $feed->url();
$href = $feed->toUrl()->toString();
$links = $this->xpath('//a[@href = :href]', [':href' => $href]);
$this->assertTrue(isset($links[0]), new FormattableMarkup('Link to href %href found.', ['%href' => $href]));
$cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
......
......@@ -32,7 +32,7 @@ public function testUpdateFeed() {
$this->assert(isset($view_link), 'The message area contains a link to a feed');
// Check feed data.
$this->assertUrl($feed->url('canonical', ['absolute' => TRUE]));
$this->assertUrl($feed->toUrl('canonical', ['absolute' => TRUE])->toString());
$this->assertTrue($this->uniqueFeed($edit['title[0][value]'], $edit['url[0][value]']), 'The feed is unique.');
// Check feed source.
......
......@@ -77,7 +77,7 @@ public function save(array $form, FormStateInterface $form_state) {
);
}
else {
$form_state->setRedirectUrl($block->urlInfo('collection'));
$form_state->setRedirectUrl($block->toUrl('collection'));
}
}
else {
......
......@@ -97,7 +97,7 @@ public function save(array $form, FormStateInterface $form_state) {
$block_type = $this->entity;
$status = $block_type->save();
$edit_link = $this->entity->link($this->t('Edit'));
$edit_link = $this->entity->toLink($this->t('Edit'), 'edit-form')->toString();
$logger = $this->logger('block_content');
if ($status == SAVED_UPDATED) {
$this->messenger()->addStatus(t('Custom block type %label has been updated.', ['%label' => $block_type->label()]));
......@@ -109,7 +109,7 @@ public function save(array $form, FormStateInterface $form_state) {
$logger->notice('Custom block type %label has been added.', ['%label' => $block_type->label(), 'link' => $edit_link]);
}
$form_state->setRedirectUrl($this->entity->urlInfo('collection'));
$form_state->setRedirectUrl($this->entity->toUrl('collection'));
}
}
......@@ -38,7 +38,7 @@ public function buildHeader() {
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
$row['type'] = $entity->link();
$row['type'] = $entity->toLink(NULL, 'edit-form')->toString();
$row['description']['data']['#markup'] = $entity->getDescription();
return $row + parent::buildRow($entity);
}
......
......@@ -188,7 +188,7 @@ protected function doTestTranslationEdit() {
// We only want to test the title for non-english translations.
if ($langcode != 'en') {
$options = ['language' => $languages[$langcode]];
$url = $entity->urlInfo('edit-form', $options);
$url = $entity->toUrl('edit-form', $options);
$this->drupalGet($url);
$title = t('<em>Edit @type</em> @title [%language translation]', [
......
......@@ -104,7 +104,7 @@ protected function loadBooks() {
foreach ($book_links as $link) {
$nid = $link['nid'];
if (isset($nodes[$nid]) && $nodes[$nid]->status) {
$link['url'] = $nodes[$nid]->urlInfo();
$link['url'] = $nodes[$nid]->toUrl();
$link['title'] = $nodes[$nid]->label();
$link['type'] = $nodes[$nid]->bundle();
$this->books[$link['bid']] = $link;
......@@ -577,7 +577,7 @@ protected function buildItems(array $tree) {
$element['attributes'] = new Attribute();
$element['title'] = $data['link']['title'];
$node = $this->entityManager->getStorage('node')->load($data['link']['nid']);
$element['url'] = $node->urlInfo();
$element['url'] = $node->toUrl();
$element['localized_options'] = !empty($data['link']['localized_options']) ? $data['link']['localized_options'] : [];
$element['localized_options']['set_active_class'] = TRUE;
$element['below'] = $data['below'] ? $this->buildItems($data['below']) : [];
......
......@@ -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.', ['%title' => $node->label(), 'link' => $node->link($this->t('View'))]);
$this->logger('content')->notice('book: updated %title.', ['%title' => $node->label(), 'link' => $node->toLink($this->t('View'))->toString()]);
}
}
}
......
......@@ -122,7 +122,7 @@ public function save(array $form, FormStateInterface $form_state) {
if (isset($this->entity->book['parent_mismatch']) && $this->entity->book['parent_mismatch']) {
// This will usually only happen when JS is disabled.
$this->messenger()->addStatus($this->t('The post has been added to the selected book. You may now position it relative to other pages.'));
$form_state->setRedirectUrl($this->entity->urlInfo('book-outline-form'));
$form_state->setRedirectUrl($this->entity->toUrl('book-outline-form'));
}
else {
$this->messenger()->addStatus($this->t('The book outline has been updated.'));
......
......@@ -94,7 +94,7 @@ public function getQuestion() {
* {@inheritdoc}
*/
public function getCancelUrl() {
return $this->node->urlInfo();
return $this->node->toUrl();
}
/**
......
......@@ -81,23 +81,23 @@ public function testBookNavigationCacheContext() {
$this->drupalLogin($this->bookAuthor);
// On non-node route.
$this->drupalGet($this->adminUser->urlInfo());
$this->drupalGet($this->adminUser->toUrl());
$this->assertRaw('[route.book_navigation]=book.none');
// On non-book node route.
$this->drupalGet($page->urlInfo());
$this->drupalGet($page->toUrl());
$this->assertRaw('[route.book_navigation]=book.none');
// On book node route.
$this->drupalGet($book_nodes[0]->urlInfo());
$this->drupalGet($book_nodes[0]->toUrl());
$this->assertRaw('[route.book_navigation]=0|2|3');
$this->drupalGet($book_nodes[1]->urlInfo());
$this->drupalGet($book_nodes[1]->toUrl());
$this->assertRaw('[route.book_navigation]=0|2|3|4');
$this->drupalGet($book_nodes[2]->urlInfo());
$this->drupalGet($book_nodes[2]->toUrl());
$this->assertRaw('[route.book_navigation]=0|2|3|5');
$this->drupalGet($book_nodes[3]->urlInfo());
$this->drupalGet($book_nodes[3]->toUrl());
$this->assertRaw('[route.book_navigation]=0|2|6');
$this->drupalGet($book_nodes[4]->urlInfo());
$this->drupalGet($book_nodes[4]->toUrl());
$this->assertRaw('[route.book_navigation]=0|2|7');
}
......@@ -366,11 +366,11 @@ public function testBookDelete() {
// Tests directly deleting a book parent.
$nodes = $this->createBook();
$this->drupalLogin($this->adminUser);
$this->drupalGet($this->book->urlInfo('delete-form'));
$this->drupalGet($this->book->toUrl('delete-form'));
$this->assertRaw(t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', ['%title' => $this->book->label()]));
// Delete parent, and visit a child page.
$this->drupalPostForm($this->book->urlInfo('delete-form'), [], t('Delete'));
$this->drupalGet($nodes[0]->urlInfo());
$this->drupalPostForm($this->book->toUrl('delete-form'), [], t('Delete'));
$this->drupalGet($nodes[0]->toUrl());
$this->assertResponse(200);
$this->assertText($nodes[0]->label());
// The book parents should be updated.
......
......@@ -102,7 +102,7 @@ public function checkBookNode(EntityInterface $node, $nodes, $previous, $up, $ne
// Check previous, up, and next links.
if ($previous) {
/** @var \Drupal\Core\Url $url */
$url = $previous->urlInfo();
$url = $previous->toUrl();
$url->setOptions(['attributes' => ['rel' => ['prev'], 'title' => t('Go to previous page')]]);
$text = new FormattableMarkup('<b>‹</b> @label', ['@label' => $previous->label()]);
$this->assertRaw(\Drupal::l($text, $url), 'Previous page link found.');
......@@ -110,14 +110,14 @@ public function checkBookNode(EntityInterface $node, $nodes, $previous, $up, $ne
if ($up) {
/** @var \Drupal\Core\Url $url */
$url = $up->urlInfo();
$url = $up->toUrl();
$url->setOptions(['attributes' => ['title' => t('Go to parent page')]]);
$this->assertRaw(\Drupal::l('Up', $url), 'Up page link found.');
}
if ($next) {
/** @var \Drupal\Core\Url $url */
$url = $next->urlInfo();
$url = $next->toUrl();
$url->setOptions(['attributes' => ['rel' => ['next'], 'title' => t('Go to next page')]]);
$text = new FormattableMarkup('@label <b>›</b>', ['@label' => $next->label()]);
$this->assertRaw(\Drupal::l($text, $url), 'Next page link found.');
......@@ -127,7 +127,7 @@ public function checkBookNode(EntityInterface $node, $nodes, $previous, $up, $ne
$expected_breadcrumb = [];
$expected_breadcrumb[] = \Drupal::url('<front>');
foreach ($breadcrumb as $a_node) {
$expected_breadcrumb[] = $a_node->url();
$expected_breadcrumb[] = $a_node->toUrl()->toString();
}
// Fetch links in the current breadcrumb.
......
......@@ -240,7 +240,7 @@ function comment_entity_view(array &$build, EntityInterface $entity, EntityViewD
];
$entity->rss_elements[] = [
'key' => 'comments',
'value' => $entity->url('canonical', $options),
'value' => $entity->toUrl('canonical', $options)->toString(),
];
}
}
......
......@@ -180,12 +180,12 @@ function comment_tokens($type, $tokens, array $data, array $options, BubbleableM
// Comment related URLs.
case 'url':
$url_options['fragment'] = 'comment-' . $comment->id();
$replacements[$original] = $comment->url('canonical', $url_options);
$replacements[$original] = $comment->toUrl('canonical', $url_options)->toString();
break;
case 'edit-url':
$url_options['fragment'] = NULL;
$replacements[$original] = $comment->url('edit-form', $url_options);
$replacements[$original] = $comment->toUrl('edit-form', $url_options)->toString();
break;
case 'author':
......
......@@ -48,7 +48,7 @@ public function build(RouteMatchInterface $route_match) {
$breadcrumb->addLink(Link::createFromRoute($this->t('Home'), '<front>'));
$entity = $route_match->getParameter('entity');
$breadcrumb->addLink(new Link($entity->label(), $entity->urlInfo()));
$breadcrumb->addLink(new Link($entity->label(), $entity->toUrl()));
$breadcrumb->addCacheableDependency($entity);
if (($pid = $route_match->getParameter('pid')) && ($comment = $this->storage->load($pid))) {
......@@ -56,7 +56,7 @@ public function build(RouteMatchInterface $route_match) {
$breadcrumb->addCacheableDependency($comment);
// Display link to parent comment.
// @todo Clean-up permalink in https://www.drupal.org/node/2198041
$breadcrumb->addLink(new Link($comment->getSubject(), $comment->urlInfo()));
$breadcrumb->addLink(new Link($comment->getSubject(), $comment->toUrl()));
}
return $breadcrumb;
......
......@@ -369,7 +369,7 @@ public function save(array $form, FormStateInterface $form_state) {
$comment = $this->entity;
$entity = $comment->getCommentedEntity();
$field_name = $comment->getFieldName();
$uri = $entity->urlInfo();
$uri = $entity->toUrl();
$logger = $this->logger('comment');
if ($this->currentUser->hasPermission('post comments') && ($this->currentUser->hasPermission('administer comments') || $entity->{$field_name}->status == CommentItemInterface::OPEN)) {
......@@ -379,7 +379,7 @@ public function save(array $form, FormStateInterface $form_state) {
// Add a log entry.
$logger->notice('Comment posted: %subject.', [
'%subject' => $comment->getSubject(),
'link' => $this->l(t('View'), $comment->urlInfo()->setOption('fragment', 'comment-' . $comment->id())),
'link' => $this->l(t('View'), $comment->toUrl()->setOption('fragment', 'comment-' . $comment->id())),
]);
// Explain the approval queue if necessary.
......
......@@ -169,14 +169,14 @@ protected function buildLinks(CommentInterface $entity, EntityInterface $comment
if ($entity->access('delete')) {
$links['comment-delete'] = [
'title' => t('Delete'),
'url' => $entity->urlInfo('delete-form'),
'url' => $entity->toUrl('delete-form'),
];
}
if ($entity->access('update')) {
$links['comment-edit'] = [
'title' => t('Edit'),
'url' => $entity->urlInfo('edit-form'),
'url' => $entity->toUrl('edit-form'),
];
}
if ($entity->access('create')) {
......@@ -205,7 +205,7 @@ protected function buildLinks(CommentInterface $entity, EntityInterface $comment
if ($this->moduleHandler->moduleExists('content_translation') && $this->access($entity)->isAllowed()) {
$links['comment-translations'] = [
'title' => t('Translate'),
'url' => $entity->urlInfo('drupal:content-translation-overview'),
'url' => $entity->toUrl('drupal:content-translation-overview'),
];
}
......
......@@ -207,10 +207,10 @@ public function buildCommentedEntityLinks(FieldableEntityInterface $entity, arra
$query = $page_number ? ['page' => $page_number] : NULL;
$value = [
'new_comment_count' => (int) $new_comments,
'first_new_comment_link' => $entity->url('canonical', [
'first_new_comment_link' => $entity->toUrl('canonical', [
'query' => $query,
'fragment' => 'new',
]),
])->toString(),
];
$parents = ['comment', 'newCommentsLinks', $entity->getEntityTypeId(), $field_name, $entity->id()];
NestedArray::setValue($entity_links['comment__' . $field_name]['#attached']['drupalSettings'], $parents, $value);
......
......@@ -149,7 +149,7 @@ public function forbiddenMessage(EntityInterface $entity, $field_name) {
$destination = ['destination' => Url::fromRoute('comment.reply', $comment_reply_parameters, ['fragment' => 'comment-form'])->toString()];
}
else {
$destination = ['destination' => $entity->url('canonical', ['fragment' => 'comment-form'])];
$destination = ['destination' => $entity->toUrl('canonical', ['fragment' => 'comment-form'])->toString()];
}
if ($this->userConfig->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY) {
......
......@@ -158,7 +158,7 @@ public function save(array $form, FormStateInterface $form_state) {
$comment_type = $this->entity;
$status = $comment_type->save();
$edit_link = $this->entity->link($this->t('Edit'));
$edit_link = $this->entity->toLink($this->t('Edit'), 'edit-form')->toString();
if ($status == SAVED_UPDATED) {
$this->messenger()->addStatus(t('Comment type %label has been updated.', ['%label' => $comment_type->label()]));
$this->logger->notice('Comment type %label has been updated.', ['%label' => $comment_type->label(), 'link' => $edit_link]);
......@@ -169,7 +169,7 @@ public function save(array $form, FormStateInterface $form_state) {
$this->logger->notice('Comment type %label has been added.', ['%label' => $comment_type->label(), 'link' => $edit_link]);
}
$form_state->setRedirectUrl($comment_type->urlInfo('collection'));
$form_state->setRedirectUrl($comment_type->toUrl('collection'));
}
}
......@@ -124,7 +124,7 @@ public function commentPermalink(Request $request, CommentInterface $comment) {
// Find the current display page for this comment.
$page = $this->entityManager()->getStorage('comment')->getDisplayOrdinal($comment, $field_definition->getSetting('default_mode'), $field_definition->getSetting('per_page'));
// @todo: Cleaner sub request handling.
$subrequest_url = $entity->urlInfo()->setOption('query', ['page' => $page])->toString(TRUE);
$subrequest_url = $entity->toUrl()->setOption('query', ['page' => $page])->toString(TRUE);
$redirect_request = Request::create($subrequest_url->getGeneratedUrl(), 'GET', $request->query->all(), $request->cookies->all(), [], $request->server->all());
// Carry over the session to the subrequest.
if ($session = $request->getSession()) {
......
......@@ -211,7 +211,7 @@ public function referencedEntities() {
* {@inheritdoc}
*/
public function permalink() {
$uri = $this->urlInfo();
$uri = $this->toUrl();
$uri->setOption('fragment', 'comment-' . $this->id());
return $uri;
}
......
......@@ -215,21 +215,21 @@ public function buildForm(array $form, FormStateInterface $form_state, $type = '
'#type' => 'link',
'#title' => $commented_entity->label(),
'#access' => $commented_entity->access('view'),
'#url' => $commented_entity->urlInfo(),
'#url' => $commented_entity->toUrl(),
],
],
'changed' => $this->dateFormatter->format($comment->getChangedTimeAcrossTranslations(), 'short'),
];
$comment_uri_options = $comment->urlInfo()->getOptions() + ['query' => $destination];
$comment_uri_options = $comment->toUrl()->getOptions() + ['query' => $destination];
$links = [];
$links['edit'] = [
'title' => $this->t('Edit'),
'url' => $comment->urlInfo('edit-form', $comment_uri_options),
'url' => $comment->toUrl('edit-form', $comment_uri_options),
];
if ($this->moduleHandler->moduleExists('content_translation') && $this->moduleHandler->invoke('content_translation', 'translate_access', [$comment])->isAllowed()) {
$links['translate'] = [
'title' => $this->t('Translate'),
'url' => $comment->urlInfo('drupal:content-translation-overview', $comment_uri_options),
'url' => $comment->toUrl('drupal:content-translation-overview', $comment_uri_options),
];
}
$options[$comment->id()]['operations']['data'] = [
......
......@@ -16,7 +16,7 @@ class DeleteForm extends ContentEntityDeleteForm {
*/
public function getCancelUrl() {
// Point to the entity of which this comment is a reply.
return $this->entity->get('entity_id')->entity->urlInfo();
return $this->entity->get('entity_id')->entity->toUrl();
}
/**
......
......@@ -180,7 +180,7 @@ protected function renderLink($data, ResultRow $values) {
$page_number = $entity_manager->getStorage('comment')
->getNewCommentPageNumber($this->getValue($values, 'comment_count'), $this->getValue($values), $node, $comment_field_name);
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['url'] = $node->urlInfo();
$this->options['alter']['url'] = $node->toUrl();
$this->options['alter']['query'] = $page_number ? ['page' => $page_number] : NULL;
$this->options['alter']['fragment'] = 'new';
}
......
......@@ -79,7 +79,7 @@ public function render($row) {
return;
}
$comment->link = $comment->url('canonical', ['absolute' => TRUE]);
$comment->link = $comment->toUrl('canonical', ['absolute' => TRUE])->toString();
$comment->rss_namespaces = [];
$comment->rss_elements = [
[
......
......@@ -41,7 +41,7 @@ public function testAnonymous() {
$body = 'comment body with skip comment approval';
$edit['subject[0][value]'] = $title;
$edit['comment_body[0][value]'] = $body;
$this->drupalPostForm($this->node->urlInfo(), $edit, t('Preview'));
$this->drupalPostForm($this->node->toUrl(), $edit, t('Preview'));
// Cannot use assertRaw here since both title and body are in the form.
$preview = (string) $this->cssSelect('.preview')[0]->getHtml();
$this->assertTrue(strpos($preview, $title) !== FALSE, 'Anonymous user can preview comment title.');
......@@ -54,7 +54,7 @@ public function testAnonymous() {
$body = 'comment body without skip comment approval';
$edit['subject[0][value]'] = $title;
$edit['comment_body[0][value]'] = $body;
$this->drupalPostForm($this->node->urlInfo(), $edit, t('Preview'));
$this->drupalPostForm($this-><