core/includes/theme.inc | 2 +- core/lib/Drupal/Core/StreamWrapper/PrivateStream.php | 6 +++++- core/lib/Drupal/Core/StreamWrapper/TemporaryStream.php | 2 +- core/modules/aggregator/src/Entity/Feed.php | 2 +- .../src/Plugin/aggregator/processor/DefaultProcessor.php | 5 ++++- core/modules/aggregator/src/Tests/AddFeedTest.php | 2 +- .../modules/aggregator/src/Tests/AggregatorRenderingTest.php | 6 +++--- core/modules/aggregator/src/Tests/AggregatorTestBase.php | 4 ++-- core/modules/contact/contact.module | 2 +- core/modules/forum/forum.module | 2 +- core/modules/migrate_drupal/src/Tests/d6/MigrateUserTest.php | 2 +- core/modules/rdf/rdf.module | 2 +- core/modules/rdf/src/Tests/CommentAttributesTest.php | 2 +- core/modules/rdf/src/Tests/UserAttributesTest.php | 2 +- core/modules/system/src/Tests/Menu/MenuRouterTest.php | 4 ++-- core/modules/system/src/Tests/System/DateTimeTest.php | 6 +++--- core/modules/system/src/Tests/System/SiteMaintenanceTest.php | 2 +- .../modules/system/src/Tests/System/TokenReplaceUnitTest.php | 6 +++--- core/modules/system/system.tokens.inc | 2 +- .../system/tests/modules/ajax_test/src/Form/AjaxTestForm.php | 2 +- .../EntityReferenceTaxonomyTermRssFormatter.php | 2 +- core/modules/taxonomy/src/Tests/RssTest.php | 2 +- core/modules/taxonomy/src/Tests/TokenReplaceTest.php | 6 +++--- .../taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php | 2 +- core/modules/taxonomy/src/VocabularyListBuilder.php | 2 +- core/modules/taxonomy/taxonomy.module | 6 +++--- core/modules/toolbar/toolbar.module | 2 +- core/modules/tour/src/Tests/TourTest.php | 2 +- core/modules/tracker/src/Tests/TrackerTest.php | 6 +++--- core/modules/user/src/AccountForm.php | 2 +- core/modules/user/src/AccountSettingsForm.php | 2 +- .../user/src/EventSubscriber/MaintenanceModeSubscriber.php | 8 ++++---- core/modules/user/src/Form/UserLoginForm.php | 6 +++--- core/modules/user/src/Plugin/Search/UserSearch.php | 2 +- core/modules/user/src/RegisterForm.php | 2 +- core/modules/user/src/Tests/UserBlocksTest.php | 4 ++-- core/modules/user/src/Tests/UserLoginTest.php | 4 ++-- core/modules/user/src/Tests/UserPasswordResetTest.php | 2 +- core/modules/user/src/Tests/UserTokenReplaceTest.php | 10 +++++----- core/modules/user/user.api.php | 2 +- core/modules/user/user.module | 12 ++++++++++-- core/modules/user/user.pages.inc | 2 +- core/modules/user/user.tokens.inc | 4 ++-- core/modules/views/views.module | 2 +- core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php | 6 +++++- 45 files changed, 91 insertions(+), 72 deletions(-) diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 7a45d10..d8fc129 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1798,7 +1798,7 @@ function template_preprocess_page(&$variables) { } $variables['base_path'] = base_path(); - $variables['front_page'] = url(); + $variables['front_page'] = \Drupal::url(''); $variables['language'] = $language_interface; $variables['language']->dir = $language_interface->direction ? 'rtl' : 'ltr'; $variables['logo'] = theme_get_setting('logo.url'); diff --git a/core/lib/Drupal/Core/StreamWrapper/PrivateStream.php b/core/lib/Drupal/Core/StreamWrapper/PrivateStream.php index 39b3f28..010214f 100644 --- a/core/lib/Drupal/Core/StreamWrapper/PrivateStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/PrivateStream.php @@ -7,6 +7,8 @@ namespace Drupal\Core\StreamWrapper; +use Drupal\Core\Routing\UrlGeneratorTrait; + /** * Drupal private (private://) stream wrapper class. * @@ -15,6 +17,8 @@ */ class PrivateStream extends LocalStream { + use UrlGeneratorTrait; + /** * Implements Drupal\Core\StreamWrapper\LocalStream::getDirectoryPath() */ @@ -30,6 +34,6 @@ public function getDirectoryPath() { */ function getExternalUrl() { $path = str_replace('\\', '/', $this->getTarget()); - return url('system/files/' . $path, array('absolute' => TRUE)); + return $this->url('system.files', ['scheme' => $path], ['absolute' => TRUE]); } } diff --git a/core/lib/Drupal/Core/StreamWrapper/TemporaryStream.php b/core/lib/Drupal/Core/StreamWrapper/TemporaryStream.php index 42dd4fd..f04213d 100644 --- a/core/lib/Drupal/Core/StreamWrapper/TemporaryStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/TemporaryStream.php @@ -27,6 +27,6 @@ public function getDirectoryPath() { */ public function getExternalUrl() { $path = str_replace('\\', '/', $this->getTarget()); - return url('system/temporary/' . $path, array('absolute' => TRUE)); + return $this->url('system.temporary', ['scheme' => $path], ['absolute' => TRUE]); } } diff --git a/core/modules/aggregator/src/Entity/Feed.php b/core/modules/aggregator/src/Entity/Feed.php index 0f2cc78..a428aab 100644 --- a/core/modules/aggregator/src/Entity/Feed.php +++ b/core/modules/aggregator/src/Entity/Feed.php @@ -172,7 +172,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['refresh'] = BaseFieldDefinition::create('list_integer') ->setLabel(t('Update interval')) - ->setDescription(t('The length of time between feed updates. Requires a correctly configured cron maintenance task.', array('@cron' => url('admin/reports/status')))) + ->setDescription(t('The length of time between feed updates. Requires a correctly configured cron maintenance task.', array('@cron' => \Drupal::url('system.status')))) ->setSetting('unsigned', TRUE) ->setRequired(TRUE) ->setSetting('allowed_values', $period) diff --git a/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php b/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php index 642646a..fdc10dc 100644 --- a/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php +++ b/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php @@ -17,6 +17,7 @@ use Drupal\Core\Entity\Query\QueryInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\Core\Routing\UrlGeneratorTrait; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -32,6 +33,8 @@ */ class DefaultProcessor extends AggregatorPluginSettingsBase implements ProcessorInterface, ContainerFactoryPluginInterface { + use UrlGeneratorTrait; + /** * Contains the configuration object factory. * @@ -141,7 +144,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#title' => t('Discard items older than'), '#default_value' => $this->configuration['items']['expire'], '#options' => $period, - '#description' => t('Requires a correctly configured cron maintenance task.', array('@cron' => url('admin/reports/status'))), + '#description' => t('Requires a correctly configured cron maintenance task.', array('@cron' => $this->url('system.status'))), ); $lengths = array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000); diff --git a/core/modules/aggregator/src/Tests/AddFeedTest.php b/core/modules/aggregator/src/Tests/AddFeedTest.php index 61cb0af..8b125ea 100644 --- a/core/modules/aggregator/src/Tests/AddFeedTest.php +++ b/core/modules/aggregator/src/Tests/AddFeedTest.php @@ -20,7 +20,7 @@ function testAddFeed() { $feed = $this->createFeed(); // Check feed data. - $this->assertEqual($this->getUrl(), url('aggregator/sources/add', array('absolute' => TRUE)), 'Directed to correct url.'); + $this->assertEqual($this->getUrl(), \Drupal::url('aggregator.feed_add', [], ['absolute' => TRUE]), 'Directed to correct url.'); $this->assertTrue($this->uniqueFeed($feed->label(), $feed->getUrl()), 'The feed is unique.'); // Check feed source. diff --git a/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php b/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php index d967d1b..745f256 100644 --- a/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php +++ b/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php @@ -53,8 +53,8 @@ public function testBlockLinks() { $this->assertText($block->label(), 'Feed block is displayed on the page.'); // Find the expected read_more link. - $href = 'aggregator/sources/' . $feed->id(); - $links = $this->xpath('//a[@href = :href]', array(':href' => url($href))); + $href = $feed->url(); + $links = $this->xpath('//a[@href = :href]', array(':href' => $href)); $this->assert(isset($links[0]), format_string('Link to href %href found.', array('%href' => $href))); $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags'); $cache_tags = explode(' ', $cache_tags_header); @@ -106,7 +106,7 @@ public function testFeedPage() { $this->assertTrue(!empty($titles), 'Source page contains correct title.'); // Find the expected read_more link on the sources page. - $href = 'aggregator/sources/' . $feed->id(); + $href = $feed->url(); $links = $this->xpath('//a[@href = :href]', array(':href' => url($href))); $this->assertTrue(isset($links[0]), String::format('Link to href %href found.', array('%href' => $href))); $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags'); diff --git a/core/modules/aggregator/src/Tests/AggregatorTestBase.php b/core/modules/aggregator/src/Tests/AggregatorTestBase.php index 71a0bfe..08583e9 100644 --- a/core/modules/aggregator/src/Tests/AggregatorTestBase.php +++ b/core/modules/aggregator/src/Tests/AggregatorTestBase.php @@ -87,7 +87,7 @@ function deleteFeed(FeedInterface $feed) { function getFeedEditArray($feed_url = NULL, array $edit = array()) { $feed_name = $this->randomMachineName(10); if (!$feed_url) { - $feed_url = url('rss.xml', array( + $feed_url = \Drupal::url('view.frontpage.feed_1', array( 'query' => array('feed' => $feed_name), 'absolute' => TRUE, )); @@ -115,7 +115,7 @@ function getFeedEditArray($feed_url = NULL, array $edit = array()) { function getFeedEditObject($feed_url = NULL, array $values = array()) { $feed_name = $this->randomMachineName(10); if (!$feed_url) { - $feed_url = url('rss.xml', array( + $feed_url = \Drupal::url('view.frontpage.feed_1', array( 'query' => array('feed' => $feed_name), 'absolute' => TRUE, )); diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index f1dfca7..23743a1 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -127,7 +127,7 @@ function contact_mail($key, &$message, $params) { case 'user_copy': $variables += array( '!recipient-name' => user_format_name($params['recipient']), - '!recipient-edit-url' => url('user/' . $params['recipient']->id() . '/edit', array('absolute' => TRUE, 'language' => $language)), + '!recipient-edit-url' => \Drupal::url('entity.user.edit_form', ['user' => $params['recipient']->id()], array('absolute' => TRUE, 'language' => $language)), ); $message['subject'] .= t('[!site-name] !subject', $variables, $options); $message['body'][] = t('Hello !recipient-name,', $variables, $options); diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 0e7087d..73c1bcb 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -145,7 +145,7 @@ function forum_menu_local_tasks(&$data, $route_name) { '#theme' => 'menu_local_action', '#link' => array( 'title' => t('Log in to post new content in the forum.', array( - '@login' => url('user/login', array('query' => drupal_get_destination())), + '@login' => \Drupal::url('user.login', [], array('query' => drupal_get_destination())), )), 'localized_options' => array('html' => TRUE), ), diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserTest.php index 3d564f0..53c7bdf 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserTest.php @@ -182,7 +182,7 @@ public function testUser() { // conform the Drupal >= 7. $credentials = array('name' => $source->name, 'pass' => $source->pass_plain); $this->drupalPostForm('user/login', $credentials, t('Log in')); - $this->assertNoRaw(t('Sorry, unrecognized username or password. Have you forgotten your password?', array('@password' => url('user/password', array('query' => array('name' => $source->name)))))); + $this->assertNoRaw(t('Sorry, unrecognized username or password. Have you forgotten your password?', array('@password' => \Drupal::url('user.pass', [], array('query' => array('name' => $source->name)))))); $this->drupalLogout(); } } diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index 061dd03..f407e83 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -393,7 +393,7 @@ function rdf_preprocess_username(&$variables) { // a user profile URI for it (only a homepage which cannot be used as user // profile in RDF.) if ($variables['uid'] > 0) { - $variables['attributes']['about'] = url('user/' . $variables['uid']); + $variables['attributes']['about'] = \Drupal::url('entity.user.canonical', ['user' => $variables['uid']]); } // Add RDF type of user. diff --git a/core/modules/rdf/src/Tests/CommentAttributesTest.php b/core/modules/rdf/src/Tests/CommentAttributesTest.php index 82fd967..ff2f28f 100644 --- a/core/modules/rdf/src/Tests/CommentAttributesTest.php +++ b/core/modules/rdf/src/Tests/CommentAttributesTest.php @@ -271,7 +271,7 @@ function _testBasicCommentRdfaMarkup($graph, CommentInterface $comment, $account // The comment author can be a registered user or an anonymous user. if ($comment->getOwnerId() > 0) { - $author_uri = url('user/' . $comment->getOwnerId(), array('absolute' => TRUE)); + $author_uri = \Drupal::url('entity.user.canonical', ['user' => $comment->getOwnerId()], array('absolute' => TRUE)); // Comment relation to author. $expected_value = array( 'type' => 'uri', diff --git a/core/modules/rdf/src/Tests/UserAttributesTest.php b/core/modules/rdf/src/Tests/UserAttributesTest.php index 840701a..f3ac891 100644 --- a/core/modules/rdf/src/Tests/UserAttributesTest.php +++ b/core/modules/rdf/src/Tests/UserAttributesTest.php @@ -58,7 +58,7 @@ function testUserAttributesInMarkup() { $this->drupalCreateContentType(array('type' => 'article')); foreach($authors as $author) { - $account_uri = url('user/' . $author->id(), array('absolute' => TRUE)); + $account_uri = \Drupal::url('entity.user.canonical', ['user' => $author->id()], array('absolute' => TRUE)); // Parses the user profile page where the default bundle mapping for user // should be used. diff --git a/core/modules/system/src/Tests/Menu/MenuRouterTest.php b/core/modules/system/src/Tests/Menu/MenuRouterTest.php index 3ad879c..2ea8169 100644 --- a/core/modules/system/src/Tests/Menu/MenuRouterTest.php +++ b/core/modules/system/src/Tests/Menu/MenuRouterTest.php @@ -227,11 +227,11 @@ public function testAuthUserUserLogin() { $this->drupalGet('user/login'); // Check that we got to 'user'. - $this->assertTrue($this->url == url('user/' . $this->loggedInUser->id(), array('absolute' => TRUE)), "Logged-in user redirected to user on accessing user/login"); + $this->assertTrue($this->url == \Drupal::url('entity.user.canonical', ['user' => $this->loggedInUser->id()], array('absolute' => TRUE)), "Logged-in user redirected to user on accessing user/login"); // user/register should redirect to user/UID/edit. $this->drupalGet('user/register'); - $this->assertTrue($this->url == url('user/' . $this->loggedInUser->id() . '/edit', array('absolute' => TRUE)), "Logged-in user redirected to user/UID/edit on accessing user/register"); + $this->assertTrue($this->url == \Drupal::url('entity.user.edit_form', ['user' => $this->loggedInUser->id()], array('absolute' => TRUE)), "Logged-in user redirected to user/UID/edit on accessing user/register"); } /** diff --git a/core/modules/system/src/Tests/System/DateTimeTest.php b/core/modules/system/src/Tests/System/DateTimeTest.php index 416a147..5445373 100644 --- a/core/modules/system/src/Tests/System/DateTimeTest.php +++ b/core/modules/system/src/Tests/System/DateTimeTest.php @@ -87,7 +87,7 @@ function testDateFormatConfiguration() { 'date_format_pattern' => $date_format, ); $this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format')); - $this->assertEqual($this->getUrl(), url('admin/config/regional/date-time', array('absolute' => TRUE)), 'Correct page redirection.'); + $this->assertEqual($this->getUrl(), \Drupal::url('system.date_format_list', [], array('absolute' => TRUE)), 'Correct page redirection.'); $this->assertText(t('Custom date format added.'), 'Date format added confirmation message appears.'); $this->assertText($date_format_id, 'Custom date format appears in the date format list.'); $this->assertText(t('Delete'), 'Delete link for custom date format appears.'); @@ -106,13 +106,13 @@ function testDateFormatConfiguration() { 'date_format_pattern' => 'Y m', ); $this->drupalPostForm($this->getUrl(), $edit, t('Save format')); - $this->assertEqual($this->getUrl(), url('admin/config/regional/date-time', array('absolute' => TRUE)), 'Correct page redirection.'); + $this->assertEqual($this->getUrl(), \Drupal::url('system.date_format_list', [], array('absolute' => TRUE)), 'Correct page redirection.'); $this->assertText(t('Custom date format updated.'), 'Custom date format successfully updated.'); // Delete custom date format. $this->clickLink(t('Delete')); $this->drupalPostForm('admin/config/regional/date-time/formats/manage/' . $date_format_id . '/delete', array(), t('Remove')); - $this->assertEqual($this->getUrl(), url('admin/config/regional/date-time', array('absolute' => TRUE)), 'Correct page redirection.'); + $this->assertEqual($this->getUrl(), \Drupal::url('system.date_format_list', [], array('absolute' => TRUE)), 'Correct page redirection.'); $this->assertRaw(t('Removed date format %format.', array('%format' => $name)), 'Custom date format removed.'); // Make sure the date does not exist in config. diff --git a/core/modules/system/src/Tests/System/SiteMaintenanceTest.php b/core/modules/system/src/Tests/System/SiteMaintenanceTest.php index 8fa9e2a..df33c9b 100644 --- a/core/modules/system/src/Tests/System/SiteMaintenanceTest.php +++ b/core/modules/system/src/Tests/System/SiteMaintenanceTest.php @@ -48,7 +48,7 @@ function testSiteMaintenance() { ); $this->drupalPostForm('admin/config/development/maintenance', $edit, t('Save configuration')); - $admin_message = t('Operating in maintenance mode. Go online.', array('@url' => url('admin/config/development/maintenance'))); + $admin_message = t('Operating in maintenance mode. Go online.', array('@url' => \Drupal::url('system.site_maintenance_mode'))); $user_message = t('Operating in maintenance mode.'); $offline_message = t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => \Drupal::config('system.site')->get('name'))); diff --git a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php index 907827f..2152474 100644 --- a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php +++ b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php @@ -98,9 +98,9 @@ public function testSystemSiteTokenReplacement() { $tests['[site:name]'] = String::checkPlain($config->get('name')); $tests['[site:slogan]'] = $safe_slogan; $tests['[site:mail]'] = $config->get('mail'); - $tests['[site:url]'] = url('', $url_options); - $tests['[site:url-brief]'] = preg_replace(array('!^https?://!', '!/$!'), '', url('', $url_options)); - $tests['[site:login-url]'] = url('user', $url_options); + $tests['[site:url]'] = \Drupal::url('', [], $url_options); + $tests['[site:url-brief]'] = preg_replace(array('!^https?://!', '!/$!'), '', \Drupal::url('', [], $url_options)); + $tests['[site:login-url]'] = \Drupal::url('user.page', [], $url_options); // Test to make sure that we generated something for each token. $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); diff --git a/core/modules/system/system.tokens.inc b/core/modules/system/system.tokens.inc index 43cf4a7..c6f6532 100644 --- a/core/modules/system/system.tokens.inc +++ b/core/modules/system/system.tokens.inc @@ -128,7 +128,7 @@ function system_tokens($type, $tokens, array $data = array(), array $options = a break; case 'login-url': - $replacements[$original] = url('user', $url_options); + $replacements[$original] = \Drupal::url('user.page', [], $url_options); break; } } diff --git a/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php b/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php index 4237316..4155b32 100644 --- a/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php +++ b/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestForm.php @@ -27,7 +27,7 @@ public function getFormId() { */ public function buildForm(array $form, FormStateInterface $form_state) { - $form['#action'] = url('ajax-test/dialog'); + $form['#action'] = \Drupal::url('ajax_test.dialog'); $form['description'] = array( '#markup' => '

' . t("Ajax Form contents description.") . '

', diff --git a/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php b/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php index 2cba1f9..90a0c92 100644 --- a/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php +++ b/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php @@ -37,7 +37,7 @@ public function viewElements(FieldItemListInterface $items) { 'key' => 'category', 'value' => $item->entity->label(), 'attributes' => array( - 'domain' => $item->target_id ? url('taxonomy/term/' . $item->target_id, array('absolute' => TRUE)) : '', + 'domain' => $item->target_id ? \Drupal::url('entity.taxonomy_term.canonical', ['taxonomy/term' => $item->target_id], array('absolute' => TRUE)) : '', ), ); } diff --git a/core/modules/taxonomy/src/Tests/RssTest.php b/core/modules/taxonomy/src/Tests/RssTest.php index 8ad0403..70b3f52 100644 --- a/core/modules/taxonomy/src/Tests/RssTest.php +++ b/core/modules/taxonomy/src/Tests/RssTest.php @@ -98,7 +98,7 @@ function testTaxonomyRss() { 'key' => 'category', 'value' => $term1->getName(), 'attributes' => array( - 'domain' => url('taxonomy/term/' . $term1->id(), array('absolute' => TRUE)), + 'domain' => \Drupal::url('entity.taxonomy_term.canonical', ['taxonomy/term' => $term1->id()], array('absolute' => TRUE)), ), ); $this->assertRaw(format_xml_elements(array($test_element)), 'Term is displayed when viewing the rss feed.'); diff --git a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php index 5c8c0f9..67cd11f 100644 --- a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php +++ b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php @@ -85,7 +85,7 @@ function testTaxonomyTokenReplacement() { $tests['[term:tid]'] = $term1->id(); $tests['[term:name]'] = String::checkPlain($term1->getName()); $tests['[term:description]'] = $term1->description->processed; - $tests['[term:url]'] = url('taxonomy/term/' . $term1->id(), array('absolute' => TRUE)); + $tests['[term:url]'] = \Drupal::url('entity.taxonomy_term.canonical', ['taxonomy/term' => $term1->id()], array('absolute' => TRUE)); $tests['[term:node-count]'] = 0; $tests['[term:parent:name]'] = '[term:parent:name]'; $tests['[term:vocabulary:name]'] = String::checkPlain($this->vocabulary->name); @@ -100,10 +100,10 @@ function testTaxonomyTokenReplacement() { $tests['[term:tid]'] = $term2->id(); $tests['[term:name]'] = String::checkPlain($term2->getName()); $tests['[term:description]'] = $term2->description->processed; - $tests['[term:url]'] = url('taxonomy/term/' . $term2->id(), array('absolute' => TRUE)); + $tests['[term:url]'] = \Drupal::url('entity.taxonomy_term.canonical', ['taxonomy/term' => $term2->id()], array('absolute' => TRUE)); $tests['[term:node-count]'] = 1; $tests['[term:parent:name]'] = String::checkPlain($term1->getName()); - $tests['[term:parent:url]'] = url('taxonomy/term/' . $term1->id(), array('absolute' => TRUE)); + $tests['[term:parent:url]'] = \Drupal::url('entity.taxonomy_term.canonical', ['taxonomy/term' => $term1->id()], array('absolute' => TRUE)); $tests['[term:parent:parent:name]'] = '[term:parent:parent:name]'; $tests['[term:vocabulary:name]'] = String::checkPlain($this->vocabulary->name); diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php index 0ad9f45..fb4cad2 100644 --- a/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php +++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php @@ -95,7 +95,7 @@ public function testFilterUI() { $view->save(); $this->drupalGet('admin/structure/views/nojs/handler/test_filter_taxonomy_index_tid/default/filter/tid'); $result = $this->xpath('//input[@id="edit-options-value"]/@data-autocomplete-path'); - $this->assertEqual((string) $result[0], url('taxonomy/autocomplete_vid/tags')); + $this->assertEqual((string) $result[0], \Drupal::url('taxonomy.autocomplete_vid', ['taxonomy_vocabulary' => 'tags'])); } } diff --git a/core/modules/taxonomy/src/VocabularyListBuilder.php b/core/modules/taxonomy/src/VocabularyListBuilder.php index 056c073..a5a02fc 100644 --- a/core/modules/taxonomy/src/VocabularyListBuilder.php +++ b/core/modules/taxonomy/src/VocabularyListBuilder.php @@ -80,7 +80,7 @@ public function render() { unset($this->weightKey); } $build = parent::render(); - $build['#empty'] = t('No vocabularies available. Add vocabulary.', array('@link' => url('admin/structure/taxonomy/add'))); + $build['#empty'] = t('No vocabularies available. Add vocabulary.', array('@link' => \Drupal::url('entity.taxonomy_vocabulary.add_form'))); return $build; } diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index ef5f0cf..a715c0a 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -55,7 +55,7 @@ function taxonomy_help($route_name, RouteMatchInterface $route_match) { $output .= '

' . t('Uses') . '

'; $output .= '
'; $output .= '
' . t('Creating vocabularies') . '
'; - $output .= '
' . t('Users with sufficient permissions can create vocabularies and terms through the Taxonomy page. The page listing the terms provides a drag-and-drop interface for controlling the order of the terms and sub-terms within a vocabulary, in a hierarchical fashion. A controlled vocabulary classifying music by genre with terms and sub-terms could look as follows:', array('@taxo' => url('admin/structure/taxonomy'), '@perm' => url('admin/people/permissions', array('fragment'=>'module-taxonomy')))); + $output .= '
' . t('Users with sufficient permissions can create vocabularies and terms through the Taxonomy page. The page listing the terms provides a drag-and-drop interface for controlling the order of the terms and sub-terms within a vocabulary, in a hierarchical fashion. A controlled vocabulary classifying music by genre with terms and sub-terms could look as follows:', array('@taxo' => \Drupal::url('taxonomy.vocabulary_list'), '@perm' => \Drupal::url('user.admin_permissions', [], array('fragment'=>'module-taxonomy')))); $output .= '
  • ' . t('vocabulary: Music') . '
  • '; $output .= '
    • ' . t('term: Jazz') . '
    • '; $output .= '
      • ' . t('sub-term: Swing') . '
      • '; @@ -66,9 +66,9 @@ function taxonomy_help($route_name, RouteMatchInterface $route_match) { $output .= t('You can assign a sub-term to multiple parent terms. For example, fusion can be assigned to both rock and jazz.') . '
'; $output .= '
' . t('Terms in a free-tagging vocabulary can be built gradually as you create or edit content. This is often done used for blogs or photo management applications.') . '
'; $output .= '
' . t('Assigning vocabularies to content types') . '
'; - $output .= '
' . t('Before you can use a new vocabulary to classify your content, a new Taxonomy term field must be added to a content type on its manage fields page. When adding a taxonomy field, you choose a widget to use to enter the taxonomy information on the content editing page: a select list, checkboxes, radio buttons, or an auto-complete field (to build a free-tagging vocabulary). After choosing the field type and widget, on the subsequent field settings page you can choose the desired vocabulary, whether one or multiple terms can be chosen from the vocabulary, and other settings. The same vocabulary can be added to multiple content types, by using the "Re-use existing field" section on the manage fields page.', array('@ctedit' => url('admin/structure/types'))) . '
'; + $output .= '
' . t('Before you can use a new vocabulary to classify your content, a new Taxonomy term field must be added to a content type on its manage fields page. When adding a taxonomy field, you choose a widget to use to enter the taxonomy information on the content editing page: a select list, checkboxes, radio buttons, or an auto-complete field (to build a free-tagging vocabulary). After choosing the field type and widget, on the subsequent field settings page you can choose the desired vocabulary, whether one or multiple terms can be chosen from the vocabulary, and other settings. The same vocabulary can be added to multiple content types, by using the "Re-use existing field" section on the manage fields page.', array('@ctedit' => \Drupal::url('node.overview_types'))) . '
'; $output .= '
' . t('Classifying content') . '
'; - $output .= '
' . t('After the vocabulary is assigned to the content type, you can start classifying content. The field with terms will appear on the content editing screen when you edit or add new content.', array('@addnode' => url('node/add'))) . '
'; + $output .= '
' . t('After the vocabulary is assigned to the content type, you can start classifying content. The field with terms will appear on the content editing screen when you edit or add new content.', array('@addnode' => \Drupal::url('node.add_page'))) . '
'; $output .= '
' . t('Viewing listings') . '
'; $output .= '
' . t("Each taxonomy term automatically provides a page listing content that has its classification. For example, if the taxonomy term country rock has the ID 123 (you can see this by looking at the URL when hovering on the linked term, which you can click to navigate to the listing page), then you will find this list at the path taxonomy/term/123.") . '
'; $output .= '
' . t('Extending Taxonomy module') . '
'; diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module index 0ff9648..0cfa492 100644 --- a/core/modules/toolbar/toolbar.module +++ b/core/modules/toolbar/toolbar.module @@ -27,7 +27,7 @@ function toolbar_help($route_name, RouteMatchInterface $route_match) { $output .= '

' . t('Uses') . '

'; $output .= '
'; $output .= '
' . t('Displaying administrative links') . '
'; - $output .= '
' . t('The Toolbar module displays a bar containing top-level administrative components across the top of the screen. Below that, the Toolbar module has a drawer section where it displays links provided by other modules, such as the core Shortcut module. The drawer can be hidden/shown by clicking on its corresponding tab.', array('@shortcuts-help' => url('admin/help/shortcut'))) . '
'; + $output .= '
' . t('The Toolbar module displays a bar containing top-level administrative components across the top of the screen. Below that, the Toolbar module has a drawer section where it displays links provided by other modules, such as the core Shortcut module. The drawer can be hidden/shown by clicking on its corresponding tab.', array('@shortcuts-help' => \Drupal::url('help.page', ['name' => 'shortcut']))) . '
'; $output .= '
'; return $output; } diff --git a/core/modules/tour/src/Tests/TourTest.php b/core/modules/tour/src/Tests/TourTest.php index 47a05d5..5ab6691 100644 --- a/core/modules/tour/src/Tests/TourTest.php +++ b/core/modules/tour/src/Tests/TourTest.php @@ -58,7 +58,7 @@ public function testTourFunctionality() { $elements = $this->xpath('//li[@data-id=:data_id and @class=:classes and ./p//a[@href=:href and contains(., :text)]]', array( ':classes' => 'tip-module-tour-test tip-type-text tip-tour-test-1', ':data_id' => 'tour-test-1', - ':href' => url('', array('absolute' => TRUE)), + ':href' => \Drupal::url('', [], array('absolute' => TRUE)), ':text' => 'Drupal', )); $this->assertEqual(count($elements), 1, 'Found Token replacement.'); diff --git a/core/modules/tracker/src/Tests/TrackerTest.php b/core/modules/tracker/src/Tests/TrackerTest.php index 969657a..d1896fb 100644 --- a/core/modules/tracker/src/Tests/TrackerTest.php +++ b/core/modules/tracker/src/Tests/TrackerTest.php @@ -143,7 +143,7 @@ function testTrackerNewNodes() { // Simulate the JavaScript on the node page to mark the node as read. // @todo Get rid of curlExec() once https://drupal.org/node/2074037 lands. $this->curlExec(array( - CURLOPT_URL => url('history/' . $node->id() . '/read', array('absolute' => TRUE)), + CURLOPT_URL => \Drupal::url('history.read_node', ['node' => $node->id()], array('absolute' => TRUE)), CURLOPT_HTTPHEADER => array( 'Accept: application/json', ), @@ -159,7 +159,7 @@ function testTrackerNewNodes() { // Simulate the JavaScript on the node page to mark the node as read. // @todo Get rid of curlExec() once https://drupal.org/node/2074037 lands. $this->curlExec(array( - CURLOPT_URL => url('history/' . $node->id() . '/read', array('absolute' => TRUE)), + CURLOPT_URL => \Drupal::url('history.read_node', ['node' => $node->id()], array('absolute' => TRUE)), CURLOPT_HTTPHEADER => array( 'Accept: application/json', ), @@ -188,7 +188,7 @@ function testTrackerNewComments() { // JavaScript that does this. // @todo Get rid of curlExec() once https://drupal.org/node/2074037 lands. $this->curlExec(array( - CURLOPT_URL => url('history/' . $node->id() . '/read', array('absolute' => TRUE)), + CURLOPT_URL => \Drupal::url('history.read_node', ['node' => $node->id()], array('absolute' => TRUE)), CURLOPT_HTTPHEADER => array( 'Accept: application/json', ), diff --git a/core/modules/user/src/AccountForm.php b/core/modules/user/src/AccountForm.php index ba11c0e..867f909 100644 --- a/core/modules/user/src/AccountForm.php +++ b/core/modules/user/src/AccountForm.php @@ -361,7 +361,7 @@ public function validate(array $form, FormStateInterface $form_state) { $form_state->setErrorByName('mail', $this->t('The email address %email is already taken.', array('%email' => $mail))); } else { - $form_state->setErrorByName('mail', $this->t('The email address %email is already registered. Have you forgotten your password?', array('%email' => $mail, '@password' => url('user/password')))); + $form_state->setErrorByName('mail', $this->t('The email address %email is already registered. Have you forgotten your password?', array('%email' => $mail, '@password' => \Drupal::url('user.pass')))); } } } diff --git a/core/modules/user/src/AccountSettingsForm.php b/core/modules/user/src/AccountSettingsForm.php index c03d17f..a8f7fdf 100644 --- a/core/modules/user/src/AccountSettingsForm.php +++ b/core/modules/user/src/AccountSettingsForm.php @@ -141,7 +141,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'radios', '#title' => $this->t('When cancelling a user account'), '#default_value' => $config->get('cancel_method'), - '#description' => $this->t('Users with the %select-cancel-method or %administer-users permissions can override this default method.', array('%select-cancel-method' => $this->t('Select method for cancelling account'), '%administer-users' => $this->t('Administer users'), '@permissions-url' => url('admin/people/permissions'))), + '#description' => $this->t('Users with the %select-cancel-method or %administer-users permissions can override this default method.', array('%select-cancel-method' => $this->t('Select method for cancelling account'), '%administer-users' => $this->t('Administer users'), '@permissions-url' => \Drupal::url('user.admin_permissions'))), ); $form['registration_cancellation']['user_cancel_method'] += user_cancel_methods(); foreach (Element::children($form['registration_cancellation']['user_cancel_method']) as $key) { diff --git a/core/modules/user/src/EventSubscriber/MaintenanceModeSubscriber.php b/core/modules/user/src/EventSubscriber/MaintenanceModeSubscriber.php index f6aee69..f5322dc 100644 --- a/core/modules/user/src/EventSubscriber/MaintenanceModeSubscriber.php +++ b/core/modules/user/src/EventSubscriber/MaintenanceModeSubscriber.php @@ -62,25 +62,25 @@ public function onKernelRequestMaintenance(GetResponseEvent $event) { if ($this->account->isAuthenticated() && !$this->maintenanceMode->exempt($this->account)) { user_logout(); // Redirect to homepage. - $event->setResponse(new RedirectResponse(url('', array('absolute' => TRUE)))); + $event->setResponse(new RedirectResponse(\Drupal::url('', [], array('absolute' => TRUE)))); return; } if ($this->account->isAnonymous() && $path == 'user') { // Forward anonymous user to login page. - $event->setResponse(new RedirectResponse(url('user/login', array('absolute' => TRUE)))); + $event->setResponse(new RedirectResponse(\Drupal::url('user.login', [], array('absolute' => TRUE)))); return; } } if ($this->account->isAuthenticated()) { if ($path == 'user/login') { // If user is logged in, redirect to 'user' instead of giving 403. - $event->setResponse(new RedirectResponse(url('user', array('absolute' => TRUE)))); + $event->setResponse(new RedirectResponse(\Drupal::url('user.page', [], array('absolute' => TRUE)))); return; } if ($path == 'user/register') { // Authenticated user should be redirected to user edit page. - $event->setResponse(new RedirectResponse(url('user/' . $this->account->id() . '/edit', array('absolute' => TRUE)))); + $event->setResponse(new RedirectResponse(\Drupal::url('entity.user.edit_form', ['user' => $this->account->id()], array('absolute' => TRUE)))); return; } } diff --git a/core/modules/user/src/Form/UserLoginForm.php b/core/modules/user/src/Form/UserLoginForm.php index e1275a4..a3c9d11 100644 --- a/core/modules/user/src/Form/UserLoginForm.php +++ b/core/modules/user/src/Form/UserLoginForm.php @@ -207,15 +207,15 @@ public function validateFinal(array &$form, FormStateInterface $form_state) { if ($flood_control_triggered = $form_state->get('flood_control_triggered')) { if ($flood_control_triggered == 'user') { - $form_state->setErrorByName('name', format_plural($flood_config->get('user_limit'), 'Sorry, there has been more than one failed login attempt for this account. It is temporarily blocked. Try again later or request a new password.', 'Sorry, there have been more than @count failed login attempts for this account. It is temporarily blocked. Try again later or request a new password.', array('@url' => url('user/password')))); + $form_state->setErrorByName('name', format_plural($flood_config->get('user_limit'), 'Sorry, there has been more than one failed login attempt for this account. It is temporarily blocked. Try again later or request a new password.', 'Sorry, there have been more than @count failed login attempts for this account. It is temporarily blocked. Try again later or request a new password.', array('@url' => \Drupal::url('user.pass')))); } else { // We did not find a uid, so the limit is IP-based. - $form_state->setErrorByName('name', $this->t('Sorry, too many failed login attempts from your IP address. This IP address is temporarily blocked. Try again later or request a new password.', array('@url' => url('user/password')))); + $form_state->setErrorByName('name', $this->t('Sorry, too many failed login attempts from your IP address. This IP address is temporarily blocked. Try again later or request a new password.', array('@url' => \Drupal::url('user.pass')))); } } else { - $form_state->setErrorByName('name', $this->t('Sorry, unrecognized username or password. Have you forgotten your password?', array('@password' => url('user/password', array('query' => array('name' => $form_state->getValue('name'))))))); + $form_state->setErrorByName('name', $this->t('Sorry, unrecognized username or password. Have you forgotten your password?', array('@password' => \Drupal::url('user.pass', [], array('query' => array('name' => $form_state->getValue('name'))))))); $accounts = $this->userStorage->loadByProperties(array('name' => $form_state->getValue('name'))); if (!empty($accounts)) { $this->logger('user')->notice('Login attempt failed for %user.', array('%user' => $form_state->getValue('name'))); diff --git a/core/modules/user/src/Plugin/Search/UserSearch.php b/core/modules/user/src/Plugin/Search/UserSearch.php index b50e0d8..fd51a74 100644 --- a/core/modules/user/src/Plugin/Search/UserSearch.php +++ b/core/modules/user/src/Plugin/Search/UserSearch.php @@ -143,7 +143,7 @@ public function execute() { foreach ($accounts as $account) { $result = array( 'title' => $account->getUsername(), - 'link' => url('user/' . $account->id(), array('absolute' => TRUE)), + 'link' => \Drupal::url('entity.user.canonical', ['user' => $account->id()], array('absolute' => TRUE)), ); 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 35fc9e8..fb59502 100644 --- a/core/modules/user/src/RegisterForm.php +++ b/core/modules/user/src/RegisterForm.php @@ -43,7 +43,7 @@ public function form(array $form, FormStateInterface $form_state) { // If we aren't admin but already logged on, go to the user page instead. if (!$admin && $user->isAuthenticated()) { - return new RedirectResponse(url('user/' . \Drupal::currentUser()->id(), array('absolute' => TRUE))); + return new RedirectResponse(\Drupal::url('entity.user.canonical', ['user' => \Drupal::currentUser()->id()], array('absolute' => TRUE))); } $form['#attached']['library'][] = 'core/drupal.form'; diff --git a/core/modules/user/src/Tests/UserBlocksTest.php b/core/modules/user/src/Tests/UserBlocksTest.php index 9e3065f..33c892a 100644 --- a/core/modules/user/src/Tests/UserBlocksTest.php +++ b/core/modules/user/src/Tests/UserBlocksTest.php @@ -54,7 +54,7 @@ function testUserLoginBlock() { $this->assertNoText(t('User login'), 'Logged in.'); // Check that we are still on the same page. - $this->assertEqual(url('admin/people/permissions', array('absolute' => TRUE)), $this->getUrl(), 'Still on the same page after login for access denied page'); + $this->assertEqual(\Drupal::url('user.admin_permissions', [], array('absolute' => TRUE)), $this->getUrl(), 'Still on the same page after login for access denied page'); // Now, log out and repeat with a non-403 page. $this->drupalLogout(); @@ -67,7 +67,7 @@ function testUserLoginBlock() { $this->drupalLogout(); $this->drupalPostForm('http://example.com/', $edit, t('Log in'), array('external' => FALSE)); // Check that we remain on the site after login. - $this->assertEqual(url('user/' . $user->id(), array('absolute' => TRUE)), $this->getUrl(), 'Redirected to user profile page after login from the frontpage'); + $this->assertEqual(\Drupal::url('entity.user.canonical', ['user' => $user->id()], array('absolute' => TRUE)), $this->getUrl(), 'Redirected to user profile page after login from the frontpage'); } /** diff --git a/core/modules/user/src/Tests/UserLoginTest.php b/core/modules/user/src/Tests/UserLoginTest.php index 15fd7ce..e7161a5 100644 --- a/core/modules/user/src/Tests/UserLoginTest.php +++ b/core/modules/user/src/Tests/UserLoginTest.php @@ -156,11 +156,11 @@ function assertFailedLogin($account, $flood_trigger = NULL) { $this->assertNoFieldByXPath("//input[@name='pass' and @value!='']", NULL, 'Password value attribute is blank.'); if (isset($flood_trigger)) { if ($flood_trigger == 'user') { - $this->assertRaw(format_plural(\Drupal::config('user.flood')->get('user_limit'), 'Sorry, there has been more than one failed login attempt for this account. It is temporarily blocked. Try again later or request a new password.', 'Sorry, there have been more than @count failed login attempts for this account. It is temporarily blocked. Try again later or request a new password.', array('@url' => url('user/password')))); + $this->assertRaw(format_plural(\Drupal::config('user.flood')->get('user_limit'), 'Sorry, there has been more than one failed login attempt for this account. It is temporarily blocked. Try again later or request a new password.', 'Sorry, there have been more than @count failed login attempts for this account. It is temporarily blocked. Try again later or request a new password.', array('@url' => \Drupal::url('user.pass')))); } else { // No uid, so the limit is IP-based. - $this->assertRaw(t('Sorry, too many failed login attempts from your IP address. This IP address is temporarily blocked. Try again later or request a new password.', array('@url' => url('user/password')))); + $this->assertRaw(t('Sorry, too many failed login attempts from your IP address. This IP address is temporarily blocked. Try again later or request a new password.', array('@url' => \Drupal::url('user.pass')))); } } else { diff --git a/core/modules/user/src/Tests/UserPasswordResetTest.php b/core/modules/user/src/Tests/UserPasswordResetTest.php index 0ea06c0..651a4ea 100644 --- a/core/modules/user/src/Tests/UserPasswordResetTest.php +++ b/core/modules/user/src/Tests/UserPasswordResetTest.php @@ -139,7 +139,7 @@ public function testUserResetPasswordTextboxFilled() { ); $this->drupalPostForm('user', $edit, t('Log in')); $this->assertRaw(t('Sorry, unrecognized username or password. Have you forgotten your password?', - array('@password' => url('user/password', array('query' => array('name' => $edit['name'])))))); + array('@password' => \Drupal::url('user.pass', [], array('query' => array('name' => $edit['name'])))))); unset($edit['pass']); $this->drupalGet('user/password', array('query' => array('name' => $edit['name']))); $this->assertFieldByName('name', $edit['name'], 'User name found.'); diff --git a/core/modules/user/src/Tests/UserTokenReplaceTest.php b/core/modules/user/src/Tests/UserTokenReplaceTest.php index 315c4ae..ea24998 100644 --- a/core/modules/user/src/Tests/UserTokenReplaceTest.php +++ b/core/modules/user/src/Tests/UserTokenReplaceTest.php @@ -57,8 +57,8 @@ function testUserTokenReplacement() { $tests['[user:uid]'] = $account->id(); $tests['[user:name]'] = String::checkPlain(user_format_name($account)); $tests['[user:mail]'] = String::checkPlain($account->getEmail()); - $tests['[user:url]'] = url("user/" . $account->id(), $url_options); - $tests['[user:edit-url]'] = url("user/" . $account->id() . "/edit", $url_options); + $tests['[user:url]'] = \Drupal::url('entity.user.canonical', ['user' => $account->id()], $url_options); + $tests['[user:edit-url]'] = \Drupal::url('entity.user.edit_form', ['user' => $account->id()], $url_options); $tests['[user:last-login]'] = format_date($account->getLastLoginTime(), 'medium', '', NULL, $language_interface->id); $tests['[user:last-login:short]'] = format_date($account->getLastLoginTime(), 'short', '', NULL, $language_interface->id); $tests['[user:created]'] = format_date($account->getCreatedTime(), 'medium', '', NULL, $language_interface->id); @@ -89,7 +89,7 @@ function testUserTokenReplacement() { $tests['[user:cancel-url]'] = user_cancel_url($account); // Generate tokens with interface language. - $link = url('user', array('absolute' => TRUE)); + $link = \Drupal::url('user.page', [], array('absolute' => TRUE)); foreach ($tests as $input => $expected) { $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->id, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE)); $this->assertTrue(strpos($output, $link) === 0, 'Generated URL is in interface language.'); @@ -98,14 +98,14 @@ function testUserTokenReplacement() { // Generate tokens with the user's preferred language. $account->preferred_langcode = 'de'; $account->save(); - $link = url('user', array('language' => \Drupal::languageManager()->getLanguage($account->getPreferredLangcode()), 'absolute' => TRUE)); + $link = \Drupal::url('user.page', [], array('language' => \Drupal::languageManager()->getLanguage($account->getPreferredLangcode()), 'absolute' => TRUE)); foreach ($tests as $input => $expected) { $output = $token_service->replace($input, array('user' => $account), array('callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE)); $this->assertTrue(strpos($output, $link) === 0, "Generated URL is in the user's preferred language."); } // Generate tokens with one specific language. - $link = url('user', array('language' => \Drupal::languageManager()->getLanguage('de'), 'absolute' => TRUE)); + $link = \Drupal::url('user.page', [], array('language' => \Drupal::languageManager()->getLanguage('de'), 'absolute' => TRUE)); foreach ($tests as $input => $expected) { foreach (array($user1, $user2) as $account) { $output = $token_service->replace($input, array('user' => $account), array('langcode' => 'de', 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE)); diff --git a/core/modules/user/user.api.php b/core/modules/user/user.api.php index 34e9f7f..38fb651 100644 --- a/core/modules/user/user.api.php +++ b/core/modules/user/user.api.php @@ -136,7 +136,7 @@ function hook_user_login($account) { $config = \Drupal::config('system.date'); // If the user has a NULL time zone, notify them to set a time zone. if (!$account->getTimezone() && $config->get('timezone.user.configurable') && $config->get('timezone.user.warn')) { - drupal_set_message(t('Configure your account time zone setting.', array('@user-edit' => url("user/" . $account->id() . "/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone'))))); + drupal_set_message(t('Configure your account time zone setting.', array('@user-edit' => \Drupal::url('entity.user.edit_form', ['user' => $account->id()], array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone'))))); } } diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 9e52c20..2ea4682 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -680,7 +680,11 @@ function user_pass_reset_url($account, $options = array()) { $timestamp = REQUEST_TIME; $langcode = isset($options['langcode']) ? $options['langcode'] : $account->getPreferredLangcode(); $url_options = array('absolute' => TRUE, 'language' => \Drupal::languageManager()->getLanguage($langcode)); - return url("user/reset/" . $account->id() . "/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime()), $url_options); + return \Drupal::url('user.reset', [ + 'user' => $account->id(), + 'timestamp' => $timestamp, + 'hash' => user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime()), + ], $url_options); } /** @@ -708,7 +712,11 @@ function user_cancel_url($account, $options = array()) { $timestamp = REQUEST_TIME; $langcode = isset($options['langcode']) ? $options['langcode'] : $account->getPreferredLangcode(); $url_options = array('absolute' => TRUE, 'language' => \Drupal::languageManager()->getLanguage($langcode)); - return url("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime()), $url_options); + return \Drupal::url('user.cancel_confirm', [ + 'user' => $account->id(), + 'timestamp' => $timestamp, + 'hashed_pass' => user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime()) + ], $url_options); } /** diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc index b548e3b..895f84c 100644 --- a/core/modules/user/user.pages.inc +++ b/core/modules/user/user.pages.inc @@ -61,7 +61,7 @@ function user_cancel_confirm($account, $timestamp = 0, $hashed_pass = '') { } else { drupal_set_message(t('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.')); - return new RedirectResponse(url("user/" . $account->id() . "/cancel", array('absolute' => TRUE))); + return new RedirectResponse(\Drupal::url('entity.user.cancel_form', ['user' => $account->id()], array('absolute' => TRUE))); } } throw new AccessDeniedHttpException(); diff --git a/core/modules/user/user.tokens.inc b/core/modules/user/user.tokens.inc index 51579be..dcaed97 100644 --- a/core/modules/user/user.tokens.inc +++ b/core/modules/user/user.tokens.inc @@ -98,11 +98,11 @@ function user_tokens($type, $tokens, array $data = array(), array $options = arr break; case 'url': - $replacements[$original] = $account->id() ? url("user/" . $account->id(), $url_options) : t('not yet assigned'); + $replacements[$original] = $account->id() ? \Drupal::url('entity.user.canonical', ['user' => $account->id()], $url_options) : t('not yet assigned'); break; case 'edit-url': - $replacements[$original] = $account->id() ? url("user/" . $account->id() . "/edit", $url_options) : t('not yet assigned'); + $replacements[$original] = $account->id() ? \Drupal::url('entity.user.edit_form', ['user' => $account->id()], $url_options) : t('not yet assigned'); break; // These tokens are default variations on the chained tokens handled below. diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 0de48d4..46800bb 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -69,7 +69,7 @@ function views_views_pre_render($view) { if ($view->ajaxEnabled() && empty($view->is_attachment) && empty($view->live_preview)) { $settings = array( 'views' => array( - 'ajax_path' => url('views/ajax'), + 'ajax_path' => \Drupal::url('views.ajax'), 'ajaxViews' => array( 'views_dom_id:' . $view->dom_id => array( 'view_name' => $view->storage->id(), diff --git a/core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php b/core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php index 173202c..1c28718 100644 --- a/core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php +++ b/core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php @@ -39,7 +39,11 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['#title'] = $this->t('Reorder displays'); $form['#section'] = 'reorder'; - $form['#action'] = url('admin/structure/views/nojs/reorder-displays/' . $view->id() . '/' . $display_id); + $form['#action'] = \Drupal::url('views_ui.form_reorder_displays', [ + 'js' => 'nojs', + 'view' => $view->id(), + 'display_id' => $display_id, + ]); $form['view'] = array( '#type' => 'value', '#value' => $view