diff --git a/core/core.api.php b/core/core.api.php index 0cfea5b8c9..3901ce5d38 100644 --- a/core/core.api.php +++ b/core/core.api.php @@ -2138,7 +2138,7 @@ function hook_mail($key, &$message, $params) { $node = $params['node']; $variables += [ '%uid' => $node->getOwnerId(), - '%url' => $node->toUrl('canonical', ['absolute' => TRUE])->toString(), + '%url' => $node->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(), '%node_type' => node_get_type_label($node), '%title' => $node->getTitle(), '%teaser' => $node->teaser, diff --git a/core/lib/Drupal/Core/Render/Element/FormElement.php b/core/lib/Drupal/Core/Render/Element/FormElement.php index f39bb79758..d81fae902a 100644 --- a/core/lib/Drupal/Core/Render/Element/FormElement.php +++ b/core/lib/Drupal/Core/Render/Element/FormElement.php @@ -174,12 +174,12 @@ public static function validatePattern(&$element, FormStateInterface $form_state * The form element. */ public static function processAutocomplete(&$element, FormStateInterface $form_state, &$complete_form) { - $url = NULL; + $generated_url = NULL; $access = FALSE; if (!empty($element['#autocomplete_route_name'])) { $parameters = isset($element['#autocomplete_route_parameters']) ? $element['#autocomplete_route_parameters'] : []; - $url = Url::fromRoute($element['#autocomplete_route_name'], $parameters)->generate(); + $generated_url = Url::fromRoute($element['#autocomplete_route_name'], $parameters)->generate(); /** @var \Drupal\Core\Access\AccessManagerInterface $access_manager */ $access_manager = \Drupal::service('access_manager'); $access = $access_manager->checkNamedRoute($element['#autocomplete_route_name'], $parameters, \Drupal::currentUser(), TRUE); @@ -191,8 +191,8 @@ public static function processAutocomplete(&$element, FormStateInterface $form_s $element['#attributes']['class'][] = 'form-autocomplete'; $metadata->addAttachments(['library' => ['core/drupal.autocomplete']]); // Provide a data attribute for the JavaScript behavior to bind to. - $element['#attributes']['data-autocomplete-path'] = $url->toString(); - $metadata = $metadata->merge($url); + $element['#attributes']['data-autocomplete-path'] = $generated_url->toString(); + $metadata = $metadata->merge($generated_url); } $metadata ->merge(BubbleableMetadata::createFromObject($access)) diff --git a/core/lib/Drupal/Core/Render/Element/RenderElement.php b/core/lib/Drupal/Core/Render/Element/RenderElement.php index 18a38b4e3c..0e3edc8624 100644 --- a/core/lib/Drupal/Core/Render/Element/RenderElement.php +++ b/core/lib/Drupal/Core/Render/Element/RenderElement.php @@ -357,11 +357,11 @@ public static function preRenderAjaxForm($element) { // Convert \Drupal\Core\Url object to string. if (isset($settings['url']) && $settings['url'] instanceof Url) { - $url = $settings['url']->setOptions($settings['options'])->generate(); + $generated_url = $settings['url']->setOptions($settings['options'])->generate(); BubbleableMetadata::createFromRenderArray($element) - ->merge($url) + ->merge($generated_url) ->applyTo($element); - $settings['url'] = $url->toString(); + $settings['url'] = $generated_url->toString(); } else { $settings['url'] = NULL; diff --git a/core/lib/Drupal/Core/Utility/token.api.php b/core/lib/Drupal/Core/Utility/token.api.php index 4ba239f672..feb31e730d 100644 --- a/core/lib/Drupal/Core/Utility/token.api.php +++ b/core/lib/Drupal/Core/Utility/token.api.php @@ -100,7 +100,7 @@ function hook_tokens($type, $tokens, array $data, array $options, \Drupal\Core\R break; case 'edit-url': - $replacements[$original] = $node->toUrl('edit-form', $url_options)->toString(); + $replacements[$original] = $node->toUrl('edit-form', $url_options)->generate()->toString(); break; // Default values for the chained tokens handled below. diff --git a/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php b/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php index 7c7a1fb050..7641577240 100644 --- a/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php +++ b/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php @@ -60,7 +60,7 @@ public function testBlockLinks() { $this->assert(isset($links[0]), 'Item link found.'); // Find the expected read_more link. - $href = $feed->toUrl()->toString(); + $href = $feed->toUrl()->generate()->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'); @@ -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->toUrl()->toString(); + $href = $feed->toUrl()->generate()->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'); diff --git a/core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php b/core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php index 408da55337..12354601f5 100644 --- a/core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php +++ b/core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php @@ -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->toUrl('canonical', ['absolute' => TRUE])->toString()); + $this->assertUrl($feed->toUrl('canonical', ['absolute' => TRUE])->generate()->toString()); $this->assertTrue($this->uniqueFeed($edit['title[0][value]'], $edit['url[0][value]']), 'The feed is unique.'); // Check feed source. diff --git a/core/modules/book/tests/src/Functional/BookTestTrait.php b/core/modules/book/tests/src/Functional/BookTestTrait.php index 221ed1fcf5..cf940b3854 100644 --- a/core/modules/book/tests/src/Functional/BookTestTrait.php +++ b/core/modules/book/tests/src/Functional/BookTestTrait.php @@ -127,7 +127,7 @@ public function checkBookNode(EntityInterface $node, $nodes, $previous, $up, $ne $expected_breadcrumb = []; $expected_breadcrumb[] = \Drupal::url(''); foreach ($breadcrumb as $a_node) { - $expected_breadcrumb[] = $a_node->toUrl()->toString(); + $expected_breadcrumb[] = $a_node->toUrl()->generate()->toString(); } // Fetch links in the current breadcrumb. diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 8a63a7eae3..82a00b72a8 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -240,7 +240,7 @@ function comment_entity_view(array &$build, EntityInterface $entity, EntityViewD ]; $entity->rss_elements[] = [ 'key' => 'comments', - 'value' => $entity->toUrl('canonical', $options)->toString(), + 'value' => $entity->toUrl('canonical', $options)->generate()->toString(), ]; } } diff --git a/core/modules/comment/comment.tokens.inc b/core/modules/comment/comment.tokens.inc index 38529c959d..b2b2676c05 100644 --- a/core/modules/comment/comment.tokens.inc +++ b/core/modules/comment/comment.tokens.inc @@ -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->toUrl('canonical', $url_options)->toString(); + $replacements[$original] = $comment->toUrl('canonical', $url_options)->generate()->toString(); break; case 'edit-url': $url_options['fragment'] = NULL; - $replacements[$original] = $comment->toUrl('edit-form', $url_options)->toString(); + $replacements[$original] = $comment->toUrl('edit-form', $url_options)->generate()->toString(); break; case 'author': diff --git a/core/modules/comment/src/CommentLinkBuilder.php b/core/modules/comment/src/CommentLinkBuilder.php index 86dfeacadb..712a8bdb64 100644 --- a/core/modules/comment/src/CommentLinkBuilder.php +++ b/core/modules/comment/src/CommentLinkBuilder.php @@ -217,7 +217,7 @@ public function buildCommentedEntityLinks(FieldableEntityInterface $entity, arra 'first_new_comment_link' => $entity->toUrl('canonical', [ 'query' => $query, 'fragment' => 'new', - ])->toString(), + ])->generate()->toString(), ]; $parents = ['comment', 'newCommentsLinks', $entity->getEntityTypeId(), $field_name, $entity->id()]; NestedArray::setValue($entity_links['comment__' . $field_name]['#attached']['drupalSettings'], $parents, $value); diff --git a/core/modules/comment/src/CommentManager.php b/core/modules/comment/src/CommentManager.php index dc68a067be..284d7b31a1 100644 --- a/core/modules/comment/src/CommentManager.php +++ b/core/modules/comment/src/CommentManager.php @@ -172,7 +172,7 @@ public function forbiddenMessage(EntityInterface $entity, $field_name) { $destination = ['destination' => Url::fromRoute('comment.reply', $comment_reply_parameters, ['fragment' => 'comment-form'])->generate()->toString()]; } else { - $destination = ['destination' => $entity->toUrl('canonical', ['fragment' => 'comment-form'])->toString()]; + $destination = ['destination' => $entity->toUrl('canonical', ['fragment' => 'comment-form'])->generate()->toString()]; } if ($this->userConfig->get('register') != UserInterface::REGISTER_ADMINISTRATORS_ONLY) { diff --git a/core/modules/comment/src/Plugin/views/row/Rss.php b/core/modules/comment/src/Plugin/views/row/Rss.php index 023e45df84..a0dbe65ce2 100644 --- a/core/modules/comment/src/Plugin/views/row/Rss.php +++ b/core/modules/comment/src/Plugin/views/row/Rss.php @@ -79,7 +79,7 @@ public function render($row) { return; } - $comment->link = $comment->toUrl('canonical', ['absolute' => TRUE])->toString(); + $comment->link = $comment->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); $comment->rss_namespaces = []; $comment->rss_elements = [ [ diff --git a/core/modules/comment/tests/src/Functional/CommentFieldsTest.php b/core/modules/comment/tests/src/Functional/CommentFieldsTest.php index 2e64fed31c..13316798b3 100644 --- a/core/modules/comment/tests/src/Functional/CommentFieldsTest.php +++ b/core/modules/comment/tests/src/Functional/CommentFieldsTest.php @@ -135,7 +135,7 @@ public function testCommentFieldLinksNonDefaultName() { $link_info = $this->getDrupalSettings()['comment']['newCommentsLinks']['node']['comment2']['2']; $this->assertIdentical($link_info['new_comment_count'], 1); - $this->assertIdentical($link_info['first_new_comment_link'], $node->toUrl('canonical', ['fragment' => 'new'])->toString()); + $this->assertIdentical($link_info['first_new_comment_link'], $node->toUrl('canonical', ['fragment' => 'new'])->generate()->toString()); } /** diff --git a/core/modules/comment/tests/src/Functional/CommentNewIndicatorTest.php b/core/modules/comment/tests/src/Functional/CommentNewIndicatorTest.php index 5cbe2f8ece..4d7a583ba7 100644 --- a/core/modules/comment/tests/src/Functional/CommentNewIndicatorTest.php +++ b/core/modules/comment/tests/src/Functional/CommentNewIndicatorTest.php @@ -117,7 +117,7 @@ public function testCommentNewCommentsIndicator() { $expected = [ $this->node->id() => [ 'new_comment_count' => 1, - 'first_new_comment_link' => $this->node->toUrl('canonical', ['fragment' => 'new'])->toString(), + 'first_new_comment_link' => $this->node->toUrl('canonical', ['fragment' => 'new'])->generate()->toString(), ], ]; $this->assertIdentical($expected, $json); diff --git a/core/modules/comment/tests/src/Functional/CommentRssTest.php b/core/modules/comment/tests/src/Functional/CommentRssTest.php index 33122dd2cd..0476f37605 100644 --- a/core/modules/comment/tests/src/Functional/CommentRssTest.php +++ b/core/modules/comment/tests/src/Functional/CommentRssTest.php @@ -66,7 +66,7 @@ public function testCommentRss() { 'user:3', ])); - $raw = '' . $this->node->toUrl('canonical', ['fragment' => 'comments', 'absolute' => TRUE])->toString() . ''; + $raw = '' . $this->node->toUrl('canonical', ['fragment' => 'comments', 'absolute' => TRUE])->generate()->toString() . ''; $this->assertRaw($raw, 'Comments as part of RSS feed.'); // Hide comments from RSS feed and check presence. diff --git a/core/modules/comment/tests/src/Functional/CommentTokenReplaceTest.php b/core/modules/comment/tests/src/Functional/CommentTokenReplaceTest.php index cc0cc1df9c..ad8d607ed9 100644 --- a/core/modules/comment/tests/src/Functional/CommentTokenReplaceTest.php +++ b/core/modules/comment/tests/src/Functional/CommentTokenReplaceTest.php @@ -80,8 +80,8 @@ public function testCommentTokenReplacement() { $tests['[comment:title]'] = Html::escape($comment->getSubject()); $tests['[comment:body]'] = $comment->comment_body->processed; $tests['[comment:langcode]'] = $comment->language()->getId(); - $tests['[comment:url]'] = $comment->toUrl('canonical', $url_options + ['fragment' => 'comment-' . $comment->id()])->toString(); - $tests['[comment:edit-url]'] = $comment->toUrl('edit-form', $url_options)->toString(); + $tests['[comment:url]'] = $comment->toUrl('canonical', $url_options + ['fragment' => 'comment-' . $comment->id()])->generate()->toString(); + $tests['[comment:edit-url]'] = $comment->toUrl('edit-form', $url_options)->generate()->toString(); $tests['[comment:created]'] = \Drupal::service('date.formatter')->format($comment->getCreatedTime(), 'medium', ['langcode' => $language_interface->getId()]); $tests['[comment:created:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($comment->getCreatedTime(), ['langcode' => $language_interface->getId()]); $tests['[comment:changed:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($comment->getChangedTimeAcrossTranslations(), ['langcode' => $language_interface->getId()]); diff --git a/core/modules/config/tests/config_test/src/ConfigTestController.php b/core/modules/config/tests/config_test/src/ConfigTestController.php index 3a1b5f53e1..09f64d1c64 100644 --- a/core/modules/config/tests/config_test/src/ConfigTestController.php +++ b/core/modules/config/tests/config_test/src/ConfigTestController.php @@ -35,7 +35,7 @@ public function editTitle(ConfigTest $config_test) { */ public function enable(ConfigTest $config_test) { $config_test->enable()->save(); - return new RedirectResponse($config_test->toUrl('collection', ['absolute' => TRUE])->toString()); + return new RedirectResponse($config_test->toUrl('collection', ['absolute' => TRUE])->generate()->toString()); } /** @@ -49,7 +49,7 @@ public function enable(ConfigTest $config_test) { */ public function disable(ConfigTest $config_test) { $config_test->disable()->save(); - return new RedirectResponse($config_test->toUrl('collection', ['absolute' => TRUE])->toString()); + return new RedirectResponse($config_test->toUrl('collection', ['absolute' => TRUE])->generate()->toString()); } } diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index 2115fc76f6..612bf006ca 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -127,7 +127,7 @@ function contact_mail($key, &$message, $params) { '@sender-name' => $sender->getDisplayName(), ]; if ($sender->isAuthenticated()) { - $variables['@sender-url'] = $sender->toUrl('canonical', ['absolute' => TRUE, 'language' => $language])->toString(); + $variables['@sender-url'] = $sender->toUrl('canonical', ['absolute' => TRUE, 'language' => $language])->generate()->toString(); } else { $variables['@sender-url'] = $params['sender']->getEmail(); @@ -153,7 +153,7 @@ function contact_mail($key, &$message, $params) { case 'user_copy': $variables += [ '@recipient-name' => $params['recipient']->getDisplayName(), - '@recipient-edit-url' => $params['recipient']->toUrl('edit-form', ['absolute' => TRUE, 'language' => $language])->toString(), + '@recipient-edit-url' => $params['recipient']->toUrl('edit-form', ['absolute' => TRUE, 'language' => $language])->generate()->toString(), ]; $message['subject'] .= t('[@site-name] @subject', $variables, $options); $message['body'][] = t('Hello @recipient-name,', $variables, $options); diff --git a/core/modules/contact/tests/src/Functional/Views/ContactLinkTest.php b/core/modules/contact/tests/src/Functional/Views/ContactLinkTest.php index edad89cda4..def6e0ff34 100644 --- a/core/modules/contact/tests/src/Functional/Views/ContactLinkTest.php +++ b/core/modules/contact/tests/src/Functional/Views/ContactLinkTest.php @@ -100,7 +100,7 @@ public function assertContactLinks(array $accounts, array $names) { foreach ($names as $name) { $account = $accounts[$name]; - $result = $this->xpath('//div[contains(@class, "views-field-contact")]//a[contains(@href, :url)]', [':url' => $account->toUrl('contact-form')->toString()]); + $result = $this->xpath('//div[contains(@class, "views-field-contact")]//a[contains(@href, :url)]', [':url' => $account->toUrl('contact-form')->generate()->toString()]); $this->assertTrue(count($result)); } } diff --git a/core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php b/core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php index 5a8a4cf519..7516ef2a5b 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php @@ -229,10 +229,10 @@ protected function doTestTranslationOverview() { foreach ($this->langcodes as $langcode) { if ($entity->hasTranslation($langcode)) { $language = new Language(['id' => $langcode]); - $view_url = $entity->toUrl('canonical', ['language' => $language])->toString(); + $view_url = $entity->toUrl('canonical', ['language' => $language])->generate()->toString(); $elements = $this->xpath('//table//a[@href=:href]', [':href' => $view_url]); $this->assertEqual((string) $elements[0], $entity->getTranslation($langcode)->label(), format_string('Label correctly shown for %language translation.', ['%language' => $langcode])); - $edit_path = $entity->toUrl('edit-form', ['language' => $language])->toString(); + $edit_path = $entity->toUrl('edit-form', ['language' => $language])->generate()->toString(); $elements = $this->xpath('//table//ul[@class="dropbutton"]/li/a[@href=:href]', [':href' => $edit_path]); $this->assertEqual((string) $elements[0], t('Edit'), format_string('Edit link correct for %language translation.', ['%language' => $langcode])); } diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php index 024f95e91e..2b267e8114 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php @@ -222,10 +222,10 @@ protected function doTestTranslationOverview() { foreach ($this->langcodes as $langcode) { if ($entity->hasTranslation($langcode)) { $language = new Language(['id' => $langcode]); - $view_url = $entity->toUrl('canonical', ['language' => $language])->toString(); + $view_url = $entity->toUrl('canonical', ['language' => $language])->generate()->toString(); $elements = $this->xpath('//table//a[@href=:href]', [':href' => $view_url]); $this->assertEqual($elements[0]->getText(), $entity->getTranslation($langcode)->label(), new FormattableMarkup('Label correctly shown for %language translation.', ['%language' => $langcode])); - $edit_path = $entity->toUrl('edit-form', ['language' => $language])->toString(); + $edit_path = $entity->toUrl('edit-form', ['language' => $language])->generate()->toString(); $elements = $this->xpath('//table//ul[@class="dropbutton"]/li/a[@href=:href]', [':href' => $edit_path]); $this->assertEqual($elements[0]->getText(), t('Edit'), new FormattableMarkup('Edit link correct for %language translation.', ['%language' => $langcode])); } diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php index 9d4afd1e52..50c90716f3 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php @@ -171,7 +171,7 @@ protected function doTestWorkflows(UserInterface $user, $expected_status) { // Check whether the user is allowed to access the translation overview. $langcode = $this->langcodes[1]; $options['language'] = $languages[$langcode]; - $translations_url = $this->entity->toUrl('drupal:content-translation-overview', $options)->toString(); + $translations_url = $this->entity->toUrl('drupal:content-translation-overview', $options); $this->drupalGet($translations_url); $this->assertResponse($expected_status['overview'], new FormattableMarkup('The @user_label has the expected translation overview access.', $args)); @@ -203,7 +203,7 @@ protected function doTestWorkflows(UserInterface $user, $expected_status) { $this->clickLink('Edit', 2); // An editor should be pointed to the entity form in multilingual mode. // We need a new expected edit path with a new language. - $expected_edit_path = $this->entity->toUrl('edit-form', $options)->toString(); + $expected_edit_path = $this->entity->toUrl('edit-form', $options)->generate()->toString(); $this->assertUrl($expected_edit_path, [], 'The translation overview points to the edit form for editors when editing translations.'); } else { @@ -232,7 +232,7 @@ protected function doTestWorkflows(UserInterface $user, $expected_status) { // An editor should be pointed to the entity deletion form in // multilingual mode. We need a new expected delete path with a new // language. - $expected_delete_path = $this->entity->toUrl('delete-form', $options)->toString(); + $expected_delete_path = $this->entity->toUrl('delete-form', $options)->generate()->toString(); $this->assertUrl($expected_delete_path, [], 'The translation overview points to the delete form for editors when deleting translations.'); } else { diff --git a/core/modules/field/tests/src/Kernel/String/StringFormatterTest.php b/core/modules/field/tests/src/Kernel/String/StringFormatterTest.php index f6087013c1..e080899d93 100644 --- a/core/modules/field/tests/src/Kernel/String/StringFormatterTest.php +++ b/core/modules/field/tests/src/Kernel/String/StringFormatterTest.php @@ -142,11 +142,11 @@ public function testStringFormatter() { $this->renderEntityFields($entity, $this->display); $this->assertLink($value, 0); - $this->assertLinkByHref($entity->toUrl()->toString()); + $this->assertLinkByHref($entity->toUrl()->generate()->toString()); // $entity->toUrl('revision') falls back to the canonical URL if this is no // revision. - $this->assertLinkByHref($entity->toUrl('revision')->toString()); + $this->assertLinkByHref($entity->toUrl('revision')->generate()->toString()); // Make the entity a new revision. $old_revision_id = $entity->getRevisionId(); @@ -158,7 +158,7 @@ public function testStringFormatter() { $this->renderEntityFields($entity, $this->display); $this->assertLink($value2, 0); - $this->assertLinkByHref($entity->toUrl('revision')->toString()); + $this->assertLinkByHref($entity->toUrl('revision')->generate()->toString()); $this->renderEntityFields($entity_new_revision, $this->display); $this->assertLink($value, 0); @@ -175,7 +175,7 @@ public function testStringFormatter() { $this->renderEntityFields($entity_new_revision, $this->display); $this->assertLink($value, 0); - $this->assertLinkByHref($entity->toUrl('canonical')->toString()); + $this->assertLinkByHref($entity->toUrl('canonical')->generate()->toString()); } } diff --git a/core/modules/filter/src/FilterPermissions.php b/core/modules/filter/src/FilterPermissions.php index 7002bb27c1..120d1a4300 100644 --- a/core/modules/filter/src/FilterPermissions.php +++ b/core/modules/filter/src/FilterPermissions.php @@ -53,7 +53,7 @@ public function permissions() { foreach ($formats as $format) { if ($permission = $format->getPermissionName()) { $permissions[$permission] = [ - 'title' => $this->t('Use the @label text format', [':url' => $format->toUrl()->toString(), '@label' => $format->label()]), + 'title' => $this->t('Use the @label text format', [':url' => $format->toUrl()->generate()->toString(), '@label' => $format->label()]), 'description' => [ '#prefix' => '', '#markup' => $this->t('Warning: This permission may have security implications depending on how the text format is configured.'), diff --git a/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php index 144d03ee17..881e174dc5 100644 --- a/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php +++ b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php @@ -141,7 +141,7 @@ public function testStyle() { $this->assertEqual('bar', $style->getThirdPartySetting('image_module_test', 'foo'), 'Third party settings were added to the image style.'); // Ensure that the image style URI matches our expected path. - $style_uri_path = $style->toUrl()->toString(); + $style_uri_path = $style->toUrl()->generate()->toString(); $this->assertTrue(strpos($style_uri_path, $style_path) !== FALSE, 'The image style URI is correct.'); // Confirm that all effects on the image style have settings that match diff --git a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php index 4014fc8378..baec167cc2 100644 --- a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php +++ b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php @@ -169,7 +169,7 @@ public function _testImageFieldFormatters($scheme) { $elements = $this->xpath( '//a[@href=:path]/img[@src=:url and @alt=:alt and @width=:width and @height=:height]', [ - ':path' => $node->toUrl()->toString(), + ':path' => $node->toUrl()->generate()->toString(), ':url' => file_url_transform_relative(file_create_url($image['#uri'])), ':width' => $image['#width'], ':height' => $image['#height'], diff --git a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php index ff829659e3..2d85363fc2 100644 --- a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php +++ b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php @@ -49,7 +49,7 @@ public function testMenuLinkContentDeleteForm() { $this->assertRaw(t('Are you sure you want to delete the custom menu link %name?', ['%name' => $menu_link->label()])); $this->assertLink(t('Cancel')); // Make sure cancel link points to link edit - $this->assertLinkByHref($menu_link->toUrl('edit-form')->toString()); + $this->assertLinkByHref($menu_link->toUrl('edit-form')->generate()->toString()); \Drupal::service('module_installer')->install(['menu_ui']); \Drupal::service('router.builder')->rebuild(); @@ -57,7 +57,7 @@ public function testMenuLinkContentDeleteForm() { // Make sure cancel URL points to menu_ui route now. $this->drupalGet($menu_link->toUrl('delete-form')); $menu = Menu::load($menu_link->getMenuName()); - $this->assertLinkByHref($menu->toUrl('edit-form')->toString()); + $this->assertLinkByHref($menu->toUrl('edit-form')->generate()->toString()); $this->drupalPostForm(NULL, [], t('Delete')); $this->assertRaw(t('The menu link %title has been deleted.', ['%title' => $menu_link->label()])); } diff --git a/core/modules/menu_ui/src/MenuForm.php b/core/modules/menu_ui/src/MenuForm.php index 15bf106794..7f6a3e69b7 100644 --- a/core/modules/menu_ui/src/MenuForm.php +++ b/core/modules/menu_ui/src/MenuForm.php @@ -269,7 +269,7 @@ protected function buildOverviewForm(array &$form, FormStateInterface $form_stat $form['links']['#empty'] = $this->t('There are no menu links yet. Add link.', [ ':url' => $this->url('entity.menu.add_link_form', ['menu' => $this->entity->id()], [ - 'query' => ['destination' => $this->entity->toUrl('edit-form')->toString()], + 'query' => ['destination' => $this->entity->toUrl('edit-form')->generate()->toString()], ]), ]); $links = $this->buildOverviewTreeForm($tree, $delta); diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php index 36aeb6df1a..c4059592ee 100644 --- a/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php @@ -873,9 +873,9 @@ public function testExpandAllItems() { $node = $this->drupalCreateNode(['type' => 'article']); // Create three menu items, none of which are expanded. - $parent = $this->addMenuLink('', $node->toUrl()->toString(), $menu->id(), FALSE); - $child_1 = $this->addMenuLink($parent->getPluginId(), $node->toUrl()->toString(), $menu->id(), FALSE); - $child_2 = $this->addMenuLink($parent->getPluginId(), $node->toUrl()->toString(), $menu->id(), FALSE); + $parent = $this->addMenuLink('', $node->toUrl()->generate()->toString(), $menu->id(), FALSE); + $child_1 = $this->addMenuLink($parent->getPluginId(), $node->toUrl()->generate()->toString(), $menu->id(), FALSE); + $child_2 = $this->addMenuLink($parent->getPluginId(), $node->toUrl()->generate()->toString(), $menu->id(), FALSE); // The menu will not automatically show all levels of depth. $this->drupalGet(''); diff --git a/core/modules/node/node.module b/core/modules/node/node.module index c6cb29c88a..ec1cd311d7 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -620,7 +620,7 @@ function template_preprocess_node(&$variables) { $variables['author_name'] = \Drupal::service('renderer')->render($variables['elements']['uid']); unset($variables['elements']['uid']); - $variables['url'] = !$node->isNew() ? $node->toUrl('canonical')->toString() : NULL; + $variables['url'] = !$node->isNew() ? $node->toUrl('canonical')->generate()->toString() : NULL; $variables['label'] = $variables['elements']['title']; unset($variables['elements']['title']); // The 'page' variable is set to TRUE in two occasions: diff --git a/core/modules/node/node.tokens.inc b/core/modules/node/node.tokens.inc index 9b7d7f91e5..50cddb7784 100644 --- a/core/modules/node/node.tokens.inc +++ b/core/modules/node/node.tokens.inc @@ -166,11 +166,11 @@ function node_tokens($type, $tokens, array $data, array $options, BubbleableMeta break; case 'url': - $replacements[$original] = $node->toUrl('canonical', $url_options)->toString(); + $replacements[$original] = $node->toUrl('canonical', $url_options)->generate()->toString(); break; case 'edit-url': - $replacements[$original] = $node->toUrl('edit-form', $url_options)->toString(); + $replacements[$original] = $node->toUrl('edit-form', $url_options)->generate()->toString(); break; // Default values for the chained tokens handled below. diff --git a/core/modules/node/src/Plugin/Search/NodeSearch.php b/core/modules/node/src/Plugin/Search/NodeSearch.php index e4d5a0e7fc..b26a0cb67e 100644 --- a/core/modules/node/src/Plugin/Search/NodeSearch.php +++ b/core/modules/node/src/Plugin/Search/NodeSearch.php @@ -368,7 +368,7 @@ protected function prepareResults(StatementInterface $found) { ]; $result = [ - 'link' => $node->toUrl('canonical', ['absolute' => TRUE])->toString(), + 'link' => $node->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(), 'type' => $type->label(), 'title' => $node->label(), 'node' => $node, diff --git a/core/modules/node/src/Plugin/views/row/Rss.php b/core/modules/node/src/Plugin/views/row/Rss.php index 59a1df012b..22bdcf5ca5 100644 --- a/core/modules/node/src/Plugin/views/row/Rss.php +++ b/core/modules/node/src/Plugin/views/row/Rss.php @@ -103,7 +103,7 @@ public function render($row) { return; } - $node->link = $node->toUrl('canonical', ['absolute' => TRUE])->toString(); + $node->link = $node->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); $node->rss_namespaces = []; $node->rss_elements = [ [ diff --git a/core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php b/core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php index cc8e5703bb..8565e1993e 100644 --- a/core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php +++ b/core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php @@ -173,7 +173,7 @@ public function testRecentNodeBlock() { $this->drupalLogin($this->adminUser); $this->drupalGet('admin/structure/block'); $this->assertText($label, 'Block was displayed on the admin/structure/block page.'); - $this->assertLinkByHref($block->toUrl()->toString()); + $this->assertLinkByHref($block->toUrl()->generate()->toString()); } } diff --git a/core/modules/node/tests/src/Functional/NodeEditFormTest.php b/core/modules/node/tests/src/Functional/NodeEditFormTest.php index 89f891a643..8eb21c8da0 100644 --- a/core/modules/node/tests/src/Functional/NodeEditFormTest.php +++ b/core/modules/node/tests/src/Functional/NodeEditFormTest.php @@ -70,7 +70,7 @@ public function testNodeEdit() { // Check that "edit" link points to correct page. $this->clickLink(t('Edit')); - $this->assertUrl($node->toUrl('edit-form', ['absolute' => TRUE])->toString()); + $this->assertUrl($node->toUrl('edit-form', ['absolute' => TRUE])->generate()->toString()); // Check that the title and body fields are displayed with the correct values. // @todo Ideally assertLink would support HTML, but it doesn't. diff --git a/core/modules/node/tests/src/Functional/NodeViewTest.php b/core/modules/node/tests/src/Functional/NodeViewTest.php index 913a1485f5..56b003c7e2 100644 --- a/core/modules/node/tests/src/Functional/NodeViewTest.php +++ b/core/modules/node/tests/src/Functional/NodeViewTest.php @@ -21,7 +21,7 @@ public function testHtmlHeadLinks() { $this->drupalGet($node->toUrl()); $result = $this->xpath('//link[@rel = "canonical"]'); - $this->assertEqual($result[0]->getAttribute('href'), $node->toUrl()->setAbsolute()->toString()); + $this->assertEqual($result[0]->getAttribute('href'), $node->toUrl()->setAbsolute()->generate()->toString()); // Link relations are checked for access for anonymous users. $result = $this->xpath('//link[@rel = "version-history"]'); @@ -34,14 +34,14 @@ public function testHtmlHeadLinks() { $this->drupalGet($node->toUrl()); $result = $this->xpath('//link[@rel = "canonical"]'); - $this->assertEqual($result[0]->getAttribute('href'), $node->toUrl()->setAbsolute()->toString()); + $this->assertEqual($result[0]->getAttribute('href'), $node->toUrl()->setAbsolute()->generate()->toString()); // Link relations are present regardless of access for authenticated users. $result = $this->xpath('//link[@rel = "version-history"]'); - $this->assertEqual($result[0]->getAttribute('href'), $node->toUrl('version-history')->setAbsolute()->toString()); + $this->assertEqual($result[0]->getAttribute('href'), $node->toUrl('version-history')->setAbsolute()->generate()->toString()); $result = $this->xpath('//link[@rel = "edit-form"]'); - $this->assertEqual($result[0]->getAttribute('href'), $node->toUrl('edit-form')->setAbsolute()->toString()); + $this->assertEqual($result[0]->getAttribute('href'), $node->toUrl('edit-form')->setAbsolute()->generate()->toString()); // Give anonymous users access to edit the node. Do this through the UI to // ensure caches are handled properly. @@ -56,13 +56,13 @@ public function testHtmlHeadLinks() { // version-history link. $this->drupalGet($node->toUrl()); $result = $this->xpath('//link[@rel = "canonical"]'); - $this->assertEqual($result[0]->getAttribute('href'), $node->toUrl()->setAbsolute()->toString()); + $this->assertEqual($result[0]->getAttribute('href'), $node->toUrl()->setAbsolute()->generate()->toString()); $result = $this->xpath('//link[@rel = "version-history"]'); $this->assertFalse($result, 'Version history not present for anonymous users without access.'); $result = $this->xpath('//link[@rel = "edit-form"]'); - $this->assertEqual($result[0]->getAttribute('href'), $node->toUrl('edit-form')->setAbsolute()->toString()); + $this->assertEqual($result[0]->getAttribute('href'), $node->toUrl('edit-form')->setAbsolute()->generate()->toString()); } /** @@ -72,9 +72,9 @@ public function testLinkHeader() { $node = $this->drupalCreateNode(); $expected = [ - '<' . Html::escape($node->toUrl('canonical')->setAbsolute()->toString()) . '>; rel="canonical"', - '<' . Html::escape($node->toUrl('canonical')->setAbsolute()->toString(), ['alias' => TRUE]) . '>; rel="shortlink"', - '<' . Html::escape($node->toUrl('revision')->setAbsolute()->toString()) . '>; rel="revision"', + '<' . Html::escape($node->toUrl('canonical')->setAbsolute()->generate()->toString()) . '>; rel="canonical"', + '<' . Html::escape($node->toUrl('canonical')->setAbsolute()->generate()->toString(), ['alias' => TRUE]) . '>; rel="shortlink"', + '<' . Html::escape($node->toUrl('revision')->setAbsolute()->generate()->toString()) . '>; rel="revision"', ]; $this->drupalGet($node->toUrl()); diff --git a/core/modules/node/tests/src/Kernel/NodeTokenReplaceTest.php b/core/modules/node/tests/src/Kernel/NodeTokenReplaceTest.php index 016807897d..77c2d45b8c 100644 --- a/core/modules/node/tests/src/Kernel/NodeTokenReplaceTest.php +++ b/core/modules/node/tests/src/Kernel/NodeTokenReplaceTest.php @@ -67,8 +67,8 @@ public function testNodeTokenReplacement() { $tests['[node:body]'] = $node->body->processed; $tests['[node:summary]'] = $node->body->summary_processed; $tests['[node:langcode]'] = $node->language()->getId(); - $tests['[node:url]'] = $node->toUrl('canonical', $url_options)->toString(); - $tests['[node:edit-url]'] = $node->toUrl('edit-form', $url_options)->toString(); + $tests['[node:url]'] = $node->toUrl('canonical', $url_options)->generate()->toString(); + $tests['[node:edit-url]'] = $node->toUrl('edit-form', $url_options)->generate()->toString(); $tests['[node:author]'] = $account->getAccountName(); $tests['[node:author:uid]'] = $node->getOwnerId(); $tests['[node:author:name]'] = $account->getAccountName(); diff --git a/core/modules/options/tests/options_test/options_test.module b/core/modules/options/tests/options_test/options_test.module index b38d647404..97b8ad8854 100644 --- a/core/modules/options/tests/options_test/options_test.module +++ b/core/modules/options/tests/options_test/options_test.module @@ -46,7 +46,7 @@ function options_test_dynamic_values_callback(FieldStorageDefinitionInterface $d $cacheable = FALSE; $values = [ $entity->label(), - $entity->toUrl()->toString(), + $entity->toUrl()->generate()->toString(), $entity->uuid(), $entity->bundle(), ]; diff --git a/core/modules/options/tests/src/Functional/OptionsDynamicValuesApiTest.php b/core/modules/options/tests/src/Functional/OptionsDynamicValuesApiTest.php index 4f047f97f3..53505c478d 100644 --- a/core/modules/options/tests/src/Functional/OptionsDynamicValuesApiTest.php +++ b/core/modules/options/tests/src/Functional/OptionsDynamicValuesApiTest.php @@ -23,7 +23,7 @@ public function testOptionsAllowedValues() { $expected_values = [ $this->entity->label(), - $this->entity->toUrl()->toString(), + $this->entity->toUrl()->generate()->toString(), $this->entity->uuid(), $this->entity->bundle(), ]; diff --git a/core/modules/options/tests/src/Functional/OptionsDynamicValuesTestBase.php b/core/modules/options/tests/src/Functional/OptionsDynamicValuesTestBase.php index 1b39cf6da7..3db1e28c5d 100644 --- a/core/modules/options/tests/src/Functional/OptionsDynamicValuesTestBase.php +++ b/core/modules/options/tests/src/Functional/OptionsDynamicValuesTestBase.php @@ -72,7 +72,7 @@ protected function setUp() { 'label' => $this->entity->label(), 'uuid' => $this->entity->uuid(), 'bundle' => $this->entity->bundle(), - 'uri' => $this->entity->toUrl()->toString(), + 'uri' => $this->entity->toUrl()->generate()->toString(), ]; } diff --git a/core/modules/path/tests/src/Functional/PathLanguageTest.php b/core/modules/path/tests/src/Functional/PathLanguageTest.php index eae2661248..f9524ab4c6 100644 --- a/core/modules/path/tests/src/Functional/PathLanguageTest.php +++ b/core/modules/path/tests/src/Functional/PathLanguageTest.php @@ -117,7 +117,7 @@ public function testAliasTranslation() { // many levels, and we need to clear those caches. $this->container->get('language_manager')->reset(); $languages = $this->container->get('language_manager')->getLanguages(); - $url = $english_node_french_translation->toUrl('canonical', ['language' => $languages['fr']])->toString(); + $url = $english_node_french_translation->toUrl('canonical', ['language' => $languages['fr']])->generate()->toString(); $this->assertTrue(strpos($url, $edit['path[0][alias]']), 'URL contains the path alias.'); diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index 3fb5637357..c5eb3c1c6c 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -241,7 +241,7 @@ function rdf_comment_storage_load($comments) { // bubbleable metadata, because it can be outside of a render context. $comment->rdf_data['entity_uri'] = $entity->toUrl()->generate()->toString(); if ($comment->hasParentComment()) { - $comment->rdf_data['pid_uri'] = $comment->getParentComment()->toUrl()->toString(); + $comment->rdf_data['pid_uri'] = $comment->getParentComment()->toUrl()->generate()->toString(); } } } @@ -368,7 +368,7 @@ function rdf_preprocess_user(&$variables) { // will automatically describe the user. if (!empty($bundle_mapping['types'])) { $variables['attributes']['typeof'] = $bundle_mapping['types']; - $variables['attributes']['about'] = $account->toUrl()->toString(); + $variables['attributes']['about'] = $account->toUrl()->generate()->toString(); } // If we are on the user account page, add the relationship between the // sioc:UserAccount and the foaf:Person who holds the account. @@ -380,7 +380,7 @@ function rdf_preprocess_user(&$variables) { $username_meta = [ '#tag' => 'meta', '#attributes' => [ - 'about' => $account->toUrl()->toString(), + 'about' => $account->toUrl()->generate()->toString(), 'property' => $name_mapping['properties'], 'content' => $account->getDisplayName(), 'lang' => '', @@ -454,7 +454,7 @@ function rdf_preprocess_comment(&$variables) { // the URI of the resource described within the HTML element, while the // typeof attribute indicates its RDF type (e.g., sioc:Post, foaf:Document, // and so on.) - $variables['attributes']['about'] = $comment->toUrl()->toString(); + $variables['attributes']['about'] = $comment->toUrl()->generate()->toString(); $variables['attributes']['typeof'] = $bundle_mapping['types']; } @@ -549,7 +549,7 @@ function rdf_preprocess_taxonomy_term(&$variables) { $term = $variables['term']; $mapping = rdf_get_mapping('taxonomy_term', $term->bundle()); $bundle_mapping = $mapping->getPreparedBundleMapping(); - $variables['attributes']['about'] = $term->toUrl()->toString(); + $variables['attributes']['about'] = $term->toUrl()->generate()->toString(); $variables['attributes']['typeof'] = empty($bundle_mapping['types']) ? NULL : $bundle_mapping['types']; // Add RDFa markup for the taxonomy term name as metadata, if present. diff --git a/core/modules/rdf/tests/src/Functional/CommentAttributesTest.php b/core/modules/rdf/tests/src/Functional/CommentAttributesTest.php index b278c35aac..b152b1d62e 100644 --- a/core/modules/rdf/tests/src/Functional/CommentAttributesTest.php +++ b/core/modules/rdf/tests/src/Functional/CommentAttributesTest.php @@ -54,7 +54,7 @@ protected function setUp() { // Prepares commonly used URIs. $this->baseUri = \Drupal::url('', [], ['absolute' => TRUE]); - $this->nodeUri = $this->node->toUrl('canonical', ['absolute' => TRUE])->toString(); + $this->nodeUri = $this->node->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); // Set relation between node and comment. $article_mapping = rdf_get_mapping('node', 'article'); @@ -211,11 +211,11 @@ public function testCommentReplyOfRdfaMarkup() { $this->drupalLogin($this->webUser); $comment_1 = $this->saveComment($this->node->id(), $this->webUser->id()); - $comment_1_uri = $comment_1->toUrl('canonical', ['absolute' => TRUE])->toString(); + $comment_1_uri = $comment_1->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); // Posts a reply to the first comment. $comment_2 = $this->saveComment($this->node->id(), $this->webUser->id(), NULL, $comment_1->id()); - $comment_2_uri = $comment_2->toUrl('canonical', ['absolute' => TRUE])->toString(); + $comment_2_uri = $comment_2->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); $parser = new \EasyRdf_Parser_Rdfa(); $graph = new \EasyRdf_Graph(); @@ -252,7 +252,7 @@ public function testCommentReplyOfRdfaMarkup() { * An array containing information about an anonymous user. */ public function _testBasicCommentRdfaMarkup($graph, CommentInterface $comment, $account = []) { - $comment_uri = $comment->toUrl('canonical', ['absolute' => TRUE])->toString(); + $comment_uri = $comment->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); // Comment type. $expected_value = [ diff --git a/core/modules/rdf/tests/src/Functional/EntityReferenceFieldAttributesTest.php b/core/modules/rdf/tests/src/Functional/EntityReferenceFieldAttributesTest.php index 9ef3252fe6..a6d5dd7af2 100644 --- a/core/modules/rdf/tests/src/Functional/EntityReferenceFieldAttributesTest.php +++ b/core/modules/rdf/tests/src/Functional/EntityReferenceFieldAttributesTest.php @@ -86,8 +86,8 @@ public function testNodeTeaser() { // Create a term in each vocabulary. $term1 = $this->createTerm($this->vocabulary); $term2 = $this->createTerm($this->vocabulary); - $taxonomy_term_1_uri = $term1->toUrl('canonical', ['absolute' => TRUE])->toString(); - $taxonomy_term_2_uri = $term2->toUrl('canonical', ['absolute' => TRUE])->toString(); + $taxonomy_term_1_uri = $term1->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); + $taxonomy_term_2_uri = $term2->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); // Create the node. $node = $this->drupalCreateNode(['type' => 'article']); @@ -107,7 +107,7 @@ public function testNodeTeaser() { $parser->parse($graph, $html, 'rdfa', $base_uri); // Node relations to taxonomy terms. - $node_uri = $node->toUrl('canonical', ['absolute' => TRUE])->toString(); + $node_uri = $node->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); $expected_value = [ 'type' => 'uri', 'value' => $taxonomy_term_1_uri, diff --git a/core/modules/rdf/tests/src/Functional/FileFieldAttributesTest.php b/core/modules/rdf/tests/src/Functional/FileFieldAttributesTest.php index 39931cd0d1..08cbd469e6 100644 --- a/core/modules/rdf/tests/src/Functional/FileFieldAttributesTest.php +++ b/core/modules/rdf/tests/src/Functional/FileFieldAttributesTest.php @@ -84,7 +84,7 @@ public function testNodeTeaser() { $base_uri = \Drupal::url('', [], ['absolute' => TRUE]); $parser->parse($graph, $html, 'rdfa', $base_uri); - $node_uri = $this->node->toUrl('canonical', ['absolute' => TRUE])->toString(); + $node_uri = $this->node->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); $file_uri = file_create_url($this->file->getFileUri()); // Node relation to attached file. diff --git a/core/modules/rdf/tests/src/Functional/ImageFieldAttributesTest.php b/core/modules/rdf/tests/src/Functional/ImageFieldAttributesTest.php index bd62f1b009..156ca1fbba 100644 --- a/core/modules/rdf/tests/src/Functional/ImageFieldAttributesTest.php +++ b/core/modules/rdf/tests/src/Functional/ImageFieldAttributesTest.php @@ -97,7 +97,7 @@ public function testNodeTeaser() { $parser->parse($graph, $html, 'rdfa', $base_uri); // Construct the node and image URIs for testing. - $node_uri = $this->node->toUrl('canonical', ['absolute' => TRUE])->toString(); + $node_uri = $this->node->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); $image_uri = ImageStyle::load('medium')->buildUrl($this->file->getFileUri()); // Test relations from node to image. diff --git a/core/modules/rdf/tests/src/Functional/NodeAttributesTest.php b/core/modules/rdf/tests/src/Functional/NodeAttributesTest.php index ffae74b260..486db41db8 100644 --- a/core/modules/rdf/tests/src/Functional/NodeAttributesTest.php +++ b/core/modules/rdf/tests/src/Functional/NodeAttributesTest.php @@ -47,7 +47,7 @@ public function testNodeAttributes() { 'title' => $this->randomMachineName(8) . "'", ]); - $node_uri = $node->toUrl('canonical', ['absolute' => TRUE])->toString(); + $node_uri = $node->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); $base_uri = \Drupal::url('', [], ['absolute' => TRUE]); // Parses front page where the node is displayed in its teaser form. diff --git a/core/modules/rdf/tests/src/Functional/StandardProfileTest.php b/core/modules/rdf/tests/src/Functional/StandardProfileTest.php index 928b2fb48f..c6d5ed776f 100644 --- a/core/modules/rdf/tests/src/Functional/StandardProfileTest.php +++ b/core/modules/rdf/tests/src/Functional/StandardProfileTest.php @@ -170,17 +170,17 @@ protected function setUp() { $image_file = $this->article->get('field_image')->entity; $this->imageUri = ImageStyle::load('large')->buildUrl($image_file->getFileUri()); // Term. - $this->termUri = $this->term->toUrl('canonical', ['absolute' => TRUE])->toString(); + $this->termUri = $this->term->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); // Article. - $this->articleUri = $this->article->toUrl('canonical', ['absolute' => TRUE])->toString(); + $this->articleUri = $this->article->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); // Page. - $this->pageUri = $this->page->toUrl('canonical', ['absolute' => TRUE])->toString(); + $this->pageUri = $this->page->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); // Author. - $this->authorUri = $this->adminUser->toUrl('canonical', ['absolute' => TRUE])->toString(); + $this->authorUri = $this->adminUser->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); // Comment. - $this->articleCommentUri = $this->articleComment->toUrl('canonical', ['absolute' => TRUE])->toString(); + $this->articleCommentUri = $this->articleComment->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); // Commenter. - $this->commenterUri = $this->webUser->toUrl('canonical', ['absolute' => TRUE])->toString(); + $this->commenterUri = $this->webUser->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); $this->drupalLogout(); } @@ -345,7 +345,7 @@ protected function doTermRdfaTests() { * The word to use in the test assertion message. */ protected function assertRdfaCommonNodeProperties($graph, NodeInterface $node, $message_prefix) { - $uri = $node->toUrl('canonical', ['absolute' => TRUE])->toString(); + $uri = $node->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); // Title. $expected_value = [ diff --git a/core/modules/rdf/tests/src/Functional/TaxonomyAttributesTest.php b/core/modules/rdf/tests/src/Functional/TaxonomyAttributesTest.php index feb114eb51..0f88dbc58d 100644 --- a/core/modules/rdf/tests/src/Functional/TaxonomyAttributesTest.php +++ b/core/modules/rdf/tests/src/Functional/TaxonomyAttributesTest.php @@ -44,7 +44,7 @@ protected function setUp() { */ public function testTaxonomyTermRdfaAttributes() { $term = $this->createTerm($this->vocabulary); - $term_uri = $term->toUrl('canonical', ['absolute' => TRUE])->toString(); + $term_uri = $term->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); // Parses the term's page and checks that the RDF output is correct. $parser = new \EasyRdf_Parser_Rdfa(); diff --git a/core/modules/rdf/tests/src/Functional/UserAttributesTest.php b/core/modules/rdf/tests/src/Functional/UserAttributesTest.php index 17274b84e8..d180b7f822 100644 --- a/core/modules/rdf/tests/src/Functional/UserAttributesTest.php +++ b/core/modules/rdf/tests/src/Functional/UserAttributesTest.php @@ -54,7 +54,7 @@ public function testUserAttributesInMarkup() { /** @var \Drupal\user\UserInterface[] $authors */ foreach ($authors as $author) { - $account_uri = $author->toUrl('canonical', ['absolute' => TRUE])->toString(); + $account_uri = $author->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); // Parses the user profile page where the default bundle mapping for user // should be used. diff --git a/core/modules/rdf/tests/src/Kernel/Field/FieldRdfaTestBase.php b/core/modules/rdf/tests/src/Kernel/Field/FieldRdfaTestBase.php index 7d8e54bf77..0b442dfa1f 100644 --- a/core/modules/rdf/tests/src/Kernel/Field/FieldRdfaTestBase.php +++ b/core/modules/rdf/tests/src/Kernel/Field/FieldRdfaTestBase.php @@ -135,7 +135,7 @@ protected function createTestField($field_settings = []) { * The absolute URI. */ protected function getAbsoluteUri($entity) { - return $entity->toUrl('canonical', ['absolute' => TRUE])->toString(); + return $entity->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); } /** diff --git a/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php b/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php index ac3a0f007c..66238d910b 100644 --- a/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php +++ b/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php @@ -507,7 +507,7 @@ private function assertResponsiveImageFieldFormattersLink($link_type) { case 'content': // Make sure the link to the node is present. - $this->assertPattern('/toUrl()->toString(), '/') . '"(.*?)>\s*assertPattern('/toUrl()->generate()->toString(), '/') . '"(.*?)>\s*uriRelationships(), TRUE)) { - $url = $entity->toUrl('canonical', ['absolute' => TRUE])->generate(); - $headers['Location'] = $url->toString(); + $generated_url = $entity->toUrl('canonical', ['absolute' => TRUE])->generate(); + $headers['Location'] = $generated_url->toString(); } return new ModifiedResourceResponse($entity, 201, $headers); } @@ -443,13 +443,13 @@ protected function addLinkHeaders(EntityInterface $entity, Response $response) { /** @var \Drupal\Core\Http\LinkRelationTypeInterface $link_relation_type */ $link_relation_type = $this->linkRelationTypeManager->createInstance($relation_name); - $generator_url = $entity->toUrl($relation_name) + $generated_url = $entity->toUrl($relation_name) ->setAbsolute(TRUE) ->generate(); if ($response instanceof CacheableResponseInterface) { - $response->addCacheableDependency($generator_url); + $response->addCacheableDependency($generated_url); } - $uri = $generator_url->toString(); + $uri = $generated_url->toString(); $relationship = $link_relation_type->isRegistered() ? $link_relation_type->getRegisteredName() diff --git a/core/modules/serialization/src/Normalizer/EntityReferenceFieldItemNormalizer.php b/core/modules/serialization/src/Normalizer/EntityReferenceFieldItemNormalizer.php index b49262a458..bc5fe1b5ca 100644 --- a/core/modules/serialization/src/Normalizer/EntityReferenceFieldItemNormalizer.php +++ b/core/modules/serialization/src/Normalizer/EntityReferenceFieldItemNormalizer.php @@ -53,9 +53,9 @@ public function normalize($field_item, $format = NULL, array $context = []) { // Add a 'url' value if there is a reference and a canonical URL. Hard // code 'canonical' here as config entities override the default $rel // parameter value to 'edit-form. - if ($entity->hasLinkTemplate('canonical') && !$entity->isNew() && $url = $entity->toUrl('canonical')->generate()) { - $this->addCacheableDependency($context, $url); - $values['url'] = $url->toString(); + if ($entity->hasLinkTemplate('canonical') && !$entity->isNew() && $generated_url = $entity->toUrl('canonical')->generate()) { + $this->addCacheableDependency($context, $generated_url); + $values['url'] = $generated_url->toString(); } // @todo Remove in https://www.drupal.org/project/drupal/issues/2925520 // @see \Drupal\hal\Normalizer\FileEntityNormalizer diff --git a/core/modules/serialization/tests/src/Kernel/EntityResolverTest.php b/core/modules/serialization/tests/src/Kernel/EntityResolverTest.php index 9218df8027..a4405407a7 100644 --- a/core/modules/serialization/tests/src/Kernel/EntityResolverTest.php +++ b/core/modules/serialization/tests/src/Kernel/EntityResolverTest.php @@ -70,7 +70,7 @@ public function testUuidEntityResolver() { ], $field_uri => [ [ - 'href' => $entity->toUrl()->toString(), + 'href' => $entity->toUrl()->generate()->toString(), ], ], ], @@ -78,7 +78,7 @@ public function testUuidEntityResolver() { $field_uri => [ [ '_links' => [ - 'self' => $entity->toUrl()->toString(), + 'self' => $entity->toUrl()->generate()->toString(), ], 'uuid' => [ [ diff --git a/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php b/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php index c95a9d96e6..91e3f18845 100644 --- a/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php +++ b/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php @@ -141,7 +141,7 @@ public function testNormalize() { 'target_id' => (int) $this->user->id(), 'target_type' => $this->user->getEntityTypeId(), 'target_uuid' => $this->user->uuid(), - 'url' => $this->user->toUrl()->toString(), + 'url' => $this->user->toUrl()->generate()->toString(), ], ], 'revision_id' => [ @@ -223,7 +223,7 @@ public function testSerialize() { 'name' => '' . $this->values['name'] . '', 'type' => 'entity_test_mulrev', 'created' => '' . $expected_created['value'] . '' . $expected_created['format'] . '', - 'user_id' => '' . $this->user->id() . '' . $this->user->getEntityTypeId() . '' . $this->user->uuid() . '' . $this->user->toUrl()->toString() . '', + 'user_id' => '' . $this->user->id() . '' . $this->user->getEntityTypeId() . '' . $this->user->uuid() . '' . $this->user->toUrl()->generate()->toString() . '', 'revision_id' => '' . $this->entity->getRevisionId() . '', 'default_langcode' => '1', 'revision_translation_affected' => '1', diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php index 7b3e3651b6..6360a7b7d2 100644 --- a/core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php +++ b/core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php @@ -169,7 +169,7 @@ public function testNormalizeWithNewEntityReference() { $generated_url = (new GeneratedUrl())->setGeneratedUrl($test_url); $url = $this->prophesize(Url::class); - $url->toString(TRUE) + $url->generate() ->willReturn($generated_url); $entity = $this->prophesize(EntityInterface::class); diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 2daddef02d..1ef44d7669 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -839,7 +839,7 @@ function system_user_login(UserInterface $account) { ':user-edit' => $account->toUrl('edit-form', [ 'query' => \Drupal::destination()->getAsArray(), 'fragment' => 'edit-timezone', - ])->toString(), + ])->generate()->toString(), ])); } } diff --git a/core/modules/system/tests/fixtures/HtaccessTest/access_test.module.orig b/core/modules/system/tests/fixtures/HtaccessTest/access_test.module.orig deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/core/modules/system/tests/fixtures/HtaccessTest/access_test.php.orig b/core/modules/system/tests/fixtures/HtaccessTest/access_test.php.orig deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php b/core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php index bcb385bf16..27ce1e62eb 100644 --- a/core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php +++ b/core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php @@ -35,7 +35,7 @@ public function testEntityOperationAlter() { $this->drupalGet('admin/people/roles'); $roles = user_roles(); foreach ($roles as $role) { - $this->assertLinkByHref($role->toUrl()->toString() . '/test_operation'); + $this->assertLinkByHref($role->toUrl()->generate()->toString() . '/test_operation'); $this->assertLink(format_string('Test Operation: @label', ['@label' => $role->label()])); } } diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 652ba32d07..19fcfd102a 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -125,7 +125,7 @@ function taxonomy_page_attachments_alter(array &$page) { $page['#attached']['html_head_link'][] = [ [ 'rel' => $rel, - 'href' => $term->toUrl($rel)->toString(), + 'href' => $term->toUrl($rel)->generate()->toString(), ], TRUE, ]; @@ -136,7 +136,7 @@ function taxonomy_page_attachments_alter(array &$page) { $page['#attached']['html_head_link'][] = [ [ 'rel' => 'shortlink', - 'href' => $term->toUrl($rel, ['alias' => TRUE])->toString(), + 'href' => $term->toUrl($rel, ['alias' => TRUE])->generate()->toString(), ], TRUE, ]; @@ -256,7 +256,7 @@ function template_preprocess_taxonomy_term(&$variables) { /** @var \Drupal\taxonomy\TermInterface $term */ $term = $variables['term']; - $variables['url'] = $term->toUrl()->toString(); + $variables['url'] = $term->toUrl()->generate()->toString(); // We use name here because that is what appears in the UI. $variables['name'] = $variables['elements']['name']; unset($variables['elements']['name']); diff --git a/core/modules/taxonomy/taxonomy.tokens.inc b/core/modules/taxonomy/taxonomy.tokens.inc index b6931b7cbb..6dbc8d8a7e 100644 --- a/core/modules/taxonomy/taxonomy.tokens.inc +++ b/core/modules/taxonomy/taxonomy.tokens.inc @@ -116,7 +116,7 @@ function taxonomy_tokens($type, $tokens, array $data, array $options, Bubbleable break; case 'url': - $replacements[$original] = $term->toUrl('canonical', ['absolute' => TRUE])->toString(); + $replacements[$original] = $term->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); break; case 'node-count': diff --git a/core/modules/taxonomy/tests/src/Functional/RssTest.php b/core/modules/taxonomy/tests/src/Functional/RssTest.php index 906109a4a3..57eb610596 100644 --- a/core/modules/taxonomy/tests/src/Functional/RssTest.php +++ b/core/modules/taxonomy/tests/src/Functional/RssTest.php @@ -95,7 +95,7 @@ public function testTaxonomyRss() { $this->drupalGet('rss.xml'); $test_element = sprintf( '%s', - 'domain="' . $term1->toUrl('canonical', ['absolute' => TRUE])->toString() . '"', + 'domain="' . $term1->toUrl('canonical', ['absolute' => TRUE])->generate()->toString() . '"', $term1->getName() ); $this->assertRaw($test_element, 'Term is displayed when viewing the rss feed.'); diff --git a/core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php b/core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php index 1eabec0339..8741f64157 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php @@ -57,7 +57,7 @@ public function testTranslatedBreadcrumbs() { // Ensure non-translated breadcrumb is correct. $breadcrumb = [Url::fromRoute('')->generate()->toString() => 'Home']; foreach ($this->terms as $term) { - $breadcrumb[$term->toUrl()->toString()] = $term->label(); + $breadcrumb[$term->toUrl()->generate()->toString()] = $term->label(); } // The last item will not be in the breadcrumb. array_pop($breadcrumb); @@ -72,7 +72,7 @@ public function testTranslatedBreadcrumbs() { $breadcrumb = [Url::fromRoute('', [], ['language' => $languages[$this->translateToLangcode]])->generate()->toString() => 'Home']; foreach ($this->terms as $term) { $translated = $term->getTranslation($this->translateToLangcode); - $url = $translated->toUrl('canonical', ['language' => $languages[$this->translateToLangcode]])->toString(); + $url = $translated->toUrl('canonical', ['language' => $languages[$this->translateToLangcode]])->generate()->toString(); $breadcrumb[$url] = $translated->label(); } array_pop($breadcrumb); diff --git a/core/modules/taxonomy/tests/src/Functional/TokenReplaceTest.php b/core/modules/taxonomy/tests/src/Functional/TokenReplaceTest.php index e62f72895c..a9dd557fd0 100644 --- a/core/modules/taxonomy/tests/src/Functional/TokenReplaceTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TokenReplaceTest.php @@ -81,7 +81,7 @@ public function testTaxonomyTokenReplacement() { $tests['[term:tid]'] = $term1->id(); $tests['[term:name]'] = $term1->getName(); $tests['[term:description]'] = $term1->description->processed; - $tests['[term:url]'] = $term1->toUrl('canonical', ['absolute' => TRUE])->toString(); + $tests['[term:url]'] = $term1->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); $tests['[term:node-count]'] = 0; $tests['[term:parent:name]'] = '[term:parent:name]'; $tests['[term:vocabulary:name]'] = $this->vocabulary->label(); @@ -112,10 +112,10 @@ public function testTaxonomyTokenReplacement() { $tests['[term:tid]'] = $term2->id(); $tests['[term:name]'] = $term2->getName(); $tests['[term:description]'] = $term2->description->processed; - $tests['[term:url]'] = $term2->toUrl('canonical', ['absolute' => TRUE])->toString(); + $tests['[term:url]'] = $term2->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); $tests['[term:node-count]'] = 1; $tests['[term:parent:name]'] = $term1->getName(); - $tests['[term:parent:url]'] = $term1->toUrl('canonical', ['absolute' => TRUE])->toString(); + $tests['[term:parent:url]'] = $term1->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(); $tests['[term:parent:parent:name]'] = '[term:parent:parent:name]'; $tests['[term:vocabulary:name]'] = $this->vocabulary->label(); diff --git a/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldAllTermsTest.php b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldAllTermsTest.php index de313e087f..adbdc086d0 100644 --- a/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldAllTermsTest.php +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldAllTermsTest.php @@ -28,13 +28,13 @@ public function testViewsHandlerAllTermsField() { $this->executeView($view); $this->drupalGet('taxonomy_all_terms_test'); - $actual = $this->xpath('//a[@href="' . $this->term1->toUrl()->toString() . '"]'); + $actual = $this->xpath('//a[@href="' . $this->term1->toUrl()->generate()->toString() . '"]'); $this->assertEqual(count($actual), 2, 'Correct number of taxonomy term1 links'); $this->assertEqual($actual[0]->getText(), $this->term1->label()); $this->assertEqual($actual[1]->getText(), $this->term1->label()); $this->assertEscaped($this->term1->label()); - $actual = $this->xpath('//a[@href="' . $this->term2->toUrl()->toString() . '"]'); + $actual = $this->xpath('//a[@href="' . $this->term2->toUrl()->generate()->toString() . '"]'); $this->assertEqual(count($actual), 2, 'Correct number of taxonomy term2 links'); $this->assertEqual($actual[0]->getText(), $this->term2->label()); $this->assertEqual($actual[1]->getText(), $this->term2->label()); diff --git a/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php index a269c8fe0d..c4bbffb912 100644 --- a/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php @@ -153,9 +153,9 @@ public function testExposedFilter() { $this->drupalGet('test-filter-taxonomy-index-tid'); $xpath = $this->xpath('//div[@class="view-content"]//a'); $this->assertIdentical(2, count($xpath)); - $xpath = $this->xpath('//div[@class="view-content"]//a[@href=:href]', [':href' => $node2->toUrl()->toString()]); + $xpath = $this->xpath('//div[@class="view-content"]//a[@href=:href]', [':href' => $node2->toUrl()->generate()->toString()]); $this->assertIdentical(1, count($xpath)); - $xpath = $this->xpath('//div[@class="view-content"]//a[@href=:href]', [':href' => $node3->toUrl()->toString()]); + $xpath = $this->xpath('//div[@class="view-content"]//a[@href=:href]', [':href' => $node3->toUrl()->generate()->toString()]); $this->assertIdentical(1, count($xpath)); // Expose the filter. @@ -173,7 +173,7 @@ public function testExposedFilter() { $this->drupalGet('test-filter-taxonomy-index-tid'); $xpath = $this->xpath('//div[@class="view-content"]//a'); $this->assertIdentical(1, count($xpath)); - $xpath = $this->xpath('//div[@class="view-content"]//a[@href=:href]', [':href' => $node1->toUrl()->toString()]); + $xpath = $this->xpath('//div[@class="view-content"]//a[@href=:href]', [':href' => $node1->toUrl()->generate()->toString()]); $this->assertIdentical(1, count($xpath)); // Set the operator to 'not empty'. @@ -186,11 +186,11 @@ public function testExposedFilter() { $this->drupalGet('test-filter-taxonomy-index-tid'); $xpath = $this->xpath('//div[@class="view-content"]//a'); $this->assertIdentical(3, count($xpath)); - $xpath = $this->xpath('//div[@class="view-content"]//a[@href=:href]', [':href' => $node2->toUrl()->toString()]); + $xpath = $this->xpath('//div[@class="view-content"]//a[@href=:href]', [':href' => $node2->toUrl()->generate()->toString()]); $this->assertIdentical(1, count($xpath)); - $xpath = $this->xpath('//div[@class="view-content"]//a[@href=:href]', [':href' => $node3->toUrl()->toString()]); + $xpath = $this->xpath('//div[@class="view-content"]//a[@href=:href]', [':href' => $node3->toUrl()->generate()->toString()]); $this->assertIdentical(1, count($xpath)); - $xpath = $this->xpath('//div[@class="view-content"]//a[@href=:href]', [':href' => $node4->toUrl()->toString()]); + $xpath = $this->xpath('//div[@class="view-content"]//a[@href=:href]', [':href' => $node4->toUrl()->generate()->toString()]); $this->assertIdentical(1, count($xpath)); // Select 'Term ID' as the field to be displayed. diff --git a/core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyDefaultArgumentTest.php b/core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyDefaultArgumentTest.php index 5ccc8e16ce..b8cabb8624 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyDefaultArgumentTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyDefaultArgumentTest.php @@ -55,7 +55,7 @@ protected function initViewWithRequest($request_url, $view_name = 'taxonomy_defa * Tests the relationship. */ public function testNodePath() { - $view = $this->initViewWithRequest($this->nodes[0]->toUrl()->toString()); + $view = $this->initViewWithRequest($this->nodes[0]->toUrl()->generate()->toString()); $expected = implode(',', [$this->term1->id(), $this->term2->id()]); $this->assertEqual($expected, $view->argument['tid']->getDefaultArgument()); @@ -77,14 +77,14 @@ public function testNodePathWithViewSelection() { ]); $field->save(); - $view = $this->initViewWithRequest($this->nodes[0]->toUrl()->toString()); + $view = $this->initViewWithRequest($this->nodes[0]->toUrl()->generate()->toString()); $expected = implode(',', [$this->term1->id(), $this->term2->id()]); $this->assertEqual($expected, $view->argument['tid']->getDefaultArgument()); } public function testTermPath() { - $view = $this->initViewWithRequest($this->term1->toUrl()->toString()); + $view = $this->initViewWithRequest($this->term1->toUrl()->generate()->toString()); $expected = $this->term1->id(); $this->assertEqual($expected, $view->argument['tid']->getDefaultArgument()); diff --git a/core/modules/user/src/Plugin/Search/UserSearch.php b/core/modules/user/src/Plugin/Search/UserSearch.php index 8bae56510c..203dc562d7 100644 --- a/core/modules/user/src/Plugin/Search/UserSearch.php +++ b/core/modules/user/src/Plugin/Search/UserSearch.php @@ -146,7 +146,7 @@ public function execute() { foreach ($accounts as $account) { $result = [ 'title' => $account->getDisplayName(), - 'link' => $account->toUrl('canonical', ['absolute' => TRUE])->toString(), + 'link' => $account->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(), ]; if ($this->currentUser->hasPermission('administer users')) { $result['title'] .= ' (' . $account->getEmail() . ')'; diff --git a/core/modules/user/src/RegisterForm.php b/core/modules/user/src/RegisterForm.php index 9cf710da38..2a61219d67 100644 --- a/core/modules/user/src/RegisterForm.php +++ b/core/modules/user/src/RegisterForm.php @@ -110,7 +110,7 @@ public function save(array $form, FormStateInterface $form_state) { // New administrative account without notification. if ($admin && !$notify) { - $this->messenger()->addStatus($this->t('Created a new user account for %name. No email has been sent.', [':url' => $account->toUrl()->toString(), '%name' => $account->getAccountName()])); + $this->messenger()->addStatus($this->t('Created a new user account for %name. No email has been sent.', [':url' => $account->toUrl()->generate()->toString(), '%name' => $account->getAccountName()])); } // No email verification required; log in user immediately. elseif (!$admin && !\Drupal::config('user.settings')->get('verify_mail') && $account->isActive()) { @@ -122,13 +122,13 @@ public function save(array $form, FormStateInterface $form_state) { // No administrator approval required. elseif ($account->isActive() || $notify) { if (!$account->getEmail() && $notify) { - $this->messenger()->addStatus($this->t('The new user %name was created without an email address, so no welcome message was sent.', [':url' => $account->toUrl()->toString(), '%name' => $account->getAccountName()])); + $this->messenger()->addStatus($this->t('The new user %name was created without an email address, so no welcome message was sent.', [':url' => $account->toUrl()->generate()->toString(), '%name' => $account->getAccountName()])); } else { $op = $notify ? 'register_admin_created' : 'register_no_approval_required'; if (_user_mail_notify($op, $account)) { if ($notify) { - $this->messenger()->addStatus($this->t('A welcome message with further instructions has been emailed to the new user %name.', [':url' => $account->toUrl()->toString(), '%name' => $account->getAccountName()])); + $this->messenger()->addStatus($this->t('A welcome message with further instructions has been emailed to the new user %name.', [':url' => $account->toUrl()->generate()->toString(), '%name' => $account->getAccountName()])); } else { $this->messenger()->addStatus($this->t('A welcome message with further instructions has been sent to your email address.')); diff --git a/core/modules/user/tests/src/Functional/UserAdminTest.php b/core/modules/user/tests/src/Functional/UserAdminTest.php index d870ba56e2..4c6f2af4f3 100644 --- a/core/modules/user/tests/src/Functional/UserAdminTest.php +++ b/core/modules/user/tests/src/Functional/UserAdminTest.php @@ -57,7 +57,7 @@ public function testUserAdmin() { $this->assertText($admin_user->getAccountName(), 'Found Admin user on admin users page'); // Test for existence of edit link in table. - $link = $user_a->toLink(t('Edit'), 'edit-form', ['query' => ['destination' => $user_a->toUrl('collection')->toString()]])->toString(); + $link = $user_a->toLink(t('Edit'), 'edit-form', ['query' => ['destination' => $user_a->toUrl('collection')->generate()->toString()]])->toString(); $this->assertRaw($link, 'Found user A edit link on admin users page'); // Test exposed filter elements. diff --git a/core/modules/user/tests/src/Functional/UserBlocksTest.php b/core/modules/user/tests/src/Functional/UserBlocksTest.php index 6c56ff1f89..0ca78ebd7b 100644 --- a/core/modules/user/tests/src/Functional/UserBlocksTest.php +++ b/core/modules/user/tests/src/Functional/UserBlocksTest.php @@ -108,7 +108,7 @@ public function testUserLoginBlock() { $this->drupalLogout(); $this->drupalPostForm('http://example.com/', $edit, t('Log in'), ['external' => FALSE]); // Check that we remain on the site after login. - $this->assertUrl($user->toUrl('canonical', ['absolute' => TRUE])->toString(), [], 'Redirected to user profile page after login from the frontpage'); + $this->assertUrl($user->toUrl('canonical', ['absolute' => TRUE])->generate()->toString(), [], 'Redirected to user profile page after login from the frontpage'); // Verify that form validation errors are displayed immediately for forms // in blocks and not on subsequent page requests. diff --git a/core/modules/user/tests/src/Functional/UserTokenReplaceTest.php b/core/modules/user/tests/src/Functional/UserTokenReplaceTest.php index eb566846c8..3c98456d09 100644 --- a/core/modules/user/tests/src/Functional/UserTokenReplaceTest.php +++ b/core/modules/user/tests/src/Functional/UserTokenReplaceTest.php @@ -65,8 +65,8 @@ public function testUserTokenReplacement() { $tests['[user:account-name]'] = $account->getAccountName(); $tests['[user:display-name]'] = $account->getDisplayName(); $tests['[user:mail]'] = $account->getEmail(); - $tests['[user:url]'] = $account->toUrl('canonical', $url_options)->toString(); - $tests['[user:edit-url]'] = $account->toUrl('edit-form', $url_options)->toString(); + $tests['[user:url]'] = $account->toUrl('canonical', $url_options)->generate()->toString(); + $tests['[user:edit-url]'] = $account->toUrl('edit-form', $url_options)->generate()->toString(); $tests['[user:last-login]'] = $date_formatter->format($account->getLastLoginTime(), 'medium', '', NULL, $language_interface->getId()); $tests['[user:last-login:short]'] = $date_formatter->format($account->getLastLoginTime(), 'short', '', NULL, $language_interface->getId()); $tests['[user:created]'] = $date_formatter->format($account->getCreatedTime(), 'medium', '', NULL, $language_interface->getId()); diff --git a/core/modules/user/user.api.php b/core/modules/user/user.api.php index 88812ea4fa..6b82328eb3 100644 --- a/core/modules/user/user.api.php +++ b/core/modules/user/user.api.php @@ -154,7 +154,7 @@ function hook_user_login(UserInterface $account) { 'query' => \Drupal::destination() ->getAsArray(), 'fragment' => 'edit-timezone', - ])->toString(), + ])->generate()->toString(), ])); } } diff --git a/core/modules/user/user.tokens.inc b/core/modules/user/user.tokens.inc index 9baf90d10e..512e862d9d 100644 --- a/core/modules/user/user.tokens.inc +++ b/core/modules/user/user.tokens.inc @@ -118,11 +118,11 @@ function user_tokens($type, $tokens, array $data, array $options, BubbleableMeta break; case 'url': - $replacements[$original] = $account->id() ? $account->toUrl('canonical', $url_options)->toString() : t('not yet assigned'); + $replacements[$original] = $account->id() ? $account->toUrl('canonical', $url_options)->generate()->toString() : t('not yet assigned'); break; case 'edit-url': - $replacements[$original] = $account->id() ? $account->toUrl('edit-form', $url_options)->toString() : t('not yet assigned'); + $replacements[$original] = $account->id() ? $account->toUrl('edit-form', $url_options)->generate()->toString() : t('not yet assigned'); break; // These tokens are default variations on the chained tokens handled below. diff --git a/core/modules/views/tests/src/Functional/Wizard/BasicTest.php b/core/modules/views/tests/src/Functional/Wizard/BasicTest.php index c2c8d2bb1d..691936faf8 100644 --- a/core/modules/views/tests/src/Functional/Wizard/BasicTest.php +++ b/core/modules/views/tests/src/Functional/Wizard/BasicTest.php @@ -85,9 +85,9 @@ public function testViewsWizardAndListing() { $this->assertEquals('2.0', $this->getSession()->getDriver()->getAttribute('//rss', 'version')); // The feed should have the same title and nodes as the page. $this->assertText($view2['page[title]']); - $this->assertRaw($node1->toUrl('canonical', ['absolute' => TRUE])->toString()); + $this->assertRaw($node1->toUrl('canonical', ['absolute' => TRUE])->generate()->toString()); $this->assertText($node1->label()); - $this->assertRaw($node2->toUrl('canonical', ['absolute' => TRUE])->toString()); + $this->assertRaw($node2->toUrl('canonical', ['absolute' => TRUE])->generate()->toString()); $this->assertText($node2->label()); // Go back to the views page and check if this view is there. diff --git a/core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php b/core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php index dad172e408..9df51c0d41 100644 --- a/core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php +++ b/core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php @@ -135,7 +135,7 @@ protected function doTestEntityLink(AccountInterface $account, $expected_results foreach ($expected_results as $template => $expected_result) { $expected_link = ''; if ($expected_result) { - $path = $entity->toUrl($info[$template]['relationship'], $info[$template]['options'])->toString(); + $path = $entity->toUrl($info[$template]['relationship'], $info[$template]['options'])->generate()->toString(); $destination = $info[$template]['destination'] ? '?destination=/' : ''; if ($info[$template]['link']) { $expected_link = '' . $info[$template]['label'] . ''; diff --git a/core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php b/core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php index 03ad765c46..100d1b228b 100644 --- a/core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php +++ b/core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php @@ -329,7 +329,7 @@ public function testFieldAliasRender() { $this->assertEqual((string) ($i + 1), $executable->getStyle()->getField($i, 'id')); $this->assertEqual('test ' . $i, $executable->getStyle()->getField($i, 'name')); $entity = EntityTest::load($i + 1); - $this->assertEqual('test ' . $i . '', (string) $executable->getStyle()->getField($i, 'name_alias')); + $this->assertEqual('test ' . $i . '', (string) $executable->getStyle()->getField($i, 'name_alias')); } } diff --git a/core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php b/core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php index 6f10ce5f10..08f3fa918d 100644 --- a/core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php +++ b/core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php @@ -167,7 +167,7 @@ protected function doTestRenderedOutput(AccountInterface $account, $check_cache $counter_output = $view->style_plugin->getField($index, 'counter'); $this->assertEqual($counter_output, $expected); - $node_url = $node->toUrl()->toString(); + $node_url = $node->toUrl()->generate()->toString(); $expected = "{$node->label()} $counter_output"; $output = $view->style_plugin->getField($index, 'title'); $this->assertEqual($output, $expected); diff --git a/core/modules/views_ui/src/ViewEditForm.php b/core/modules/views_ui/src/ViewEditForm.php index 1d4434fe0d..39c4b79cf4 100644 --- a/core/modules/views_ui/src/ViewEditForm.php +++ b/core/modules/views_ui/src/ViewEditForm.php @@ -740,7 +740,7 @@ public function renderDisplayTop(ViewUI $view) { $element['extra_actions']['#links']['revert'] = [ 'title' => $this->t('Revert view'), 'href' => "admin/structure/views/view/{$view->id()}/revert", - 'query' => ['destination' => $view->toUrl('edit-form')->toString()], + 'query' => ['destination' => $view->toUrl('edit-form')->generate()->toString()], ]; } else { diff --git a/core/modules/workspaces/tests/src/Functional/WorkspaceTest.php b/core/modules/workspaces/tests/src/Functional/WorkspaceTest.php index e4b13188c5..2583d080fe 100644 --- a/core/modules/workspaces/tests/src/Functional/WorkspaceTest.php +++ b/core/modules/workspaces/tests/src/Functional/WorkspaceTest.php @@ -136,7 +136,7 @@ public function testWorkspaceFormRevisions() { $this->assertEquals('1', $live_workspace->getRevisionId()); // Re-save the live workspace via the UI to create revision 3. - $this->drupalPostForm($live_workspace->toUrl('edit-form')->toString(), [], 'Save'); + $this->drupalPostForm($live_workspace->toUrl('edit-form')->generate()->toString(), [], 'Save'); $live_workspace = $storage->loadUnchanged('live'); $this->assertEquals('3', $live_workspace->getRevisionId()); } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/RouteProviderTest.php b/core/tests/Drupal/KernelTests/Core/Entity/RouteProviderTest.php index 42a75b06e6..b1d1971f9f 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/RouteProviderTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/RouteProviderTest.php @@ -79,13 +79,13 @@ public function testHtmlRoutes() { ]); $entity->save(); - $this->setRawContent($this->httpKernelHandle($entity->toUrl()->toString())); + $this->setRawContent($this->httpKernelHandle($entity->toUrl()->generate()->toString())); $this->assertTitle('Test title | '); - $this->setRawContent($this->httpKernelHandle($entity->toUrl('edit-form')->toString())); + $this->setRawContent($this->httpKernelHandle($entity->toUrl('edit-form')->generate()->toString())); $this->assertTitle('Edit Test title | '); - $this->setRawContent($this->httpKernelHandle($entity->toUrl('delete-form')->toString())); + $this->setRawContent($this->httpKernelHandle($entity->toUrl('delete-form')->generate()->toString())); $this->assertTitle('Are you sure you want to delete the test entity - data table Test title? | '); } @@ -122,13 +122,13 @@ public function testAdminHtmlRoutes() { ]); $entity->save(); - $this->setRawContent($this->httpKernelHandle($entity->toUrl()->toString())); + $this->setRawContent($this->httpKernelHandle($entity->toUrl()->generate()->toString())); $this->assertTitle('Test title | '); - $this->setRawContent($this->httpKernelHandle($entity->toUrl('edit-form')->toString())); + $this->setRawContent($this->httpKernelHandle($entity->toUrl('edit-form')->generate()->toString())); $this->assertTitle('Edit Test title | '); - $this->setRawContent($this->httpKernelHandle($entity->toUrl('delete-form')->toString())); + $this->setRawContent($this->httpKernelHandle($entity->toUrl('delete-form')->generate()->toString())); $this->assertTitle('Are you sure you want to delete the test entity - admin routes Test title? | '); }