diff --git a/core/includes/batch.inc b/core/includes/batch.inc index bbb43f4..786ee3c 100644 --- a/core/includes/batch.inc +++ b/core/includes/batch.inc @@ -157,7 +157,7 @@ function _batch_progress_page() { $batch['url_options']['query']['id'] = $batch['id']; $batch['url_options']['query']['op'] = $new_op; - $url = url($batch['url'], $batch['url_options']); + $url = _url($batch['url'], $batch['url_options']); $build = array( '#theme' => 'progress_bar', @@ -486,7 +486,7 @@ function _batch_finished() { } elseif ($callback === NULL) { // Default to RedirectResponse objects when nothing specified. - $url = url($_batch['source_url'], array( + $url = _url($_batch['source_url'], array( 'absolute' => TRUE, 'query' => array('op' => 'finish', 'id' => $_batch['id']), )); diff --git a/core/includes/common.inc b/core/includes/common.inc index e57821e..87e9d0e 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -638,9 +638,24 @@ function _format_date_callback(array $matches = NULL, $new_langcode = NULL) { * When creating links in modules, consider whether l() could be a better * alternative than url(). * - * @see \Drupal\Core\Routing\UrlGeneratorInterface::generateFromPath(). + * @see \Drupal\Core\Url::fromUri() + * @see \Drupal\Core\Url::fromRoute() + * @see \Drupal\Core\Url->toString() + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.0. + * Use \Drupal\Core\Url::fromRoute() for internal paths served by Drupal + * controllers or \Drupal\Core\Url::fromUri() for external paths or + * non-controller or sub-domain URIs such as core/install.php. Note that + * \Drupal\Core\Url::fromUri() expects a valid URI including the scheme - In + * the case of URIs from the same sub-domain that are not handled by Drupal + * controllers, prepend base:://. For example: + * @code + * $installer_url = \Drupal\Core\Url::fromUri('base://core/install.php')->toString(); + * $external_url = \Drupal\Core\Url::fromUri('http://example.com', ['query' => ['foo' => 'bar']])->toString(); + * $internal_url = \Drupal\Core\Url::fromRoute('system.admin')->toString(); + * @endcode */ -function url($path = NULL, array $options = array()) { +function _url($path = NULL, array $options = array()) { return \Drupal::urlGenerator()->generateFromPath($path, $options); } @@ -730,10 +745,27 @@ function drupal_http_header_attributes(array $attributes = array()) { * @return string * An HTML string containing a link to the given path. * - * @see url() + * @see _url() * @see system_page_build() + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.0. + * Use \Drupal::linkGenerator()->generate($url) where $url is an instance of + * \Drupal\Core\Url. To build a \Drupal\Core\Url object for internal paths + * served by Drupal controllers use \Drupal\Core\Url::fromRoute(). For + * external paths or non-controller or sub-domain URIs such as + * core/install.php use \Drupal\Core\Url::fromUri(). Note that + * \Drupal\Core\Url::fromUri() expects a valid URI including the scheme - In + * the case of URIs from the same sub-domain that are not handled by Drupal + * controllers, prepend base:://. For example: + * @code + * $installer_url = \Drupal\Core\Url::fromUri('base://core/install.php')->toString(); + * $installer_link = \Drupal::linkGenerator()->generate($installer_url); + * $external_url = \Drupal\Core\Url::fromUri('http://example.com', ['query' => ['foo' => 'bar']])->toString(); + * $external_link = \Drupal::linkGenerator()->generate($external_link); + * $internal_url = \Drupal\Core\Url::fromRoute('system.admin')->toString(); + * $internal_link = \Drupal::linkGenerator()->generate($internal_url); + * @endcode */ -function l($text, $path, array $options = array()) { +function _l($text, $path, array $options = array()) { // Start building a structured representation of our link to be altered later. $variables = array( 'text' => is_array($text) ? drupal_render($text) : $text, @@ -788,7 +820,7 @@ function l($text, $path, array $options = array()) { // The result of url() is a plain-text URL. Because we are using it here // in an HTML argument context, we need to encode it properly. - $url = String::checkPlain(url($variables['path'], $variables['options'])); + $url = String::checkPlain(_url($variables['path'], $variables['options'])); // Sanitize the link text if necessary. $text = $variables['options']['html'] ? $variables['text'] : String::checkPlain($variables['text']); @@ -1509,7 +1541,7 @@ function _drupal_add_js($data = NULL, $options = NULL) { $scriptPath = $GLOBALS['script_path']; $pathPrefix = ''; $current_query = \Drupal::service('request_stack')->getCurrentRequest()->query->all(); - url('', array('script' => &$scriptPath, 'prefix' => &$pathPrefix)); + _url('', array('script' => &$scriptPath, 'prefix' => &$pathPrefix)); $current_path = current_path(); $current_path_is_admin = FALSE; // The function path_is_admin() is not available on update.php pages. diff --git a/core/includes/form.inc b/core/includes/form.inc index 260ffbe..5aafe81 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -949,7 +949,7 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = NU if ($batch['progressive']) { // Now that we have a batch id, we can generate the redirection link in // the generic error message. - $batch['error_message'] = t('Please continue to the error page', array('@error_url' => url($url, array('query' => array('id' => $batch['id'], 'op' => 'finished'))))); + $batch['error_message'] = t('Please continue to the error page', array('@error_url' => _url($url, array('query' => array('id' => $batch['id'], 'op' => 'finished'))))); // Clear the way for the redirection to the batch processing page, by // saving and unsetting the 'destination', if there is any. @@ -977,7 +977,7 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = NU } else { $options['absolute'] = TRUE; - return new RedirectResponse(url($batch['url'], $options)); + return new RedirectResponse(_url($batch['url'], $options)); } } else { diff --git a/core/includes/pager.inc b/core/includes/pager.inc index 730be44..0dcfcb7 100644 --- a/core/includes/pager.inc +++ b/core/includes/pager.inc @@ -219,7 +219,7 @@ function template_preprocess_pager(&$variables) { $options = array( 'query' => pager_query_add_page($parameters, $element, 0), ); - $items['first']['href'] = url($current_path, $options); + $items['first']['href'] = _url($current_path, $options); if (isset($tags[0])) { $items['first']['text'] = $tags[0]; } @@ -228,7 +228,7 @@ function template_preprocess_pager(&$variables) { $options = array( 'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] - 1), ); - $items['previous']['href'] = url($current_path, $options); + $items['previous']['href'] = _url($current_path, $options); if (isset($tags[1])) { $items['previous']['text'] = $tags[1]; } @@ -244,7 +244,7 @@ function template_preprocess_pager(&$variables) { $options = array( 'query' => pager_query_add_page($parameters, $element, $i - 1), ); - $items['pages'][$i]['href'] = url($current_path, $options); + $items['pages'][$i]['href'] = _url($current_path, $options); if ($i == $pager_current) { $variables['current'] = $i; } @@ -261,7 +261,7 @@ function template_preprocess_pager(&$variables) { $options = array( 'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] + 1), ); - $items['next']['href'] = url($current_path, $options); + $items['next']['href'] = _url($current_path, $options); if (isset($tags[3])) { $items['next']['text'] = $tags[3]; } @@ -270,7 +270,7 @@ function template_preprocess_pager(&$variables) { $options = array( 'query' => pager_query_add_page($parameters, $element, $pager_max - 1), ); - $items['last']['href'] = url($current_path, $options); + $items['last']['href'] = _url($current_path, $options); if (isset($tags[4])) { $items['last']['text'] = $tags[4]; } diff --git a/core/includes/tablesort.inc b/core/includes/tablesort.inc index 0b3574f..0c8d25b 100644 --- a/core/includes/tablesort.inc +++ b/core/includes/tablesort.inc @@ -61,7 +61,7 @@ function tablesort_header(&$cell_content, array &$cell_attributes, array $header $ts['sort'] = 'asc'; $image = ''; } - $cell_content = l($cell_content . $image, current_path(), array( + $cell_content = _l($cell_content . $image, current_path(), array( 'attributes' => array('title' => $title), 'query' => array_merge($ts['query'], array( 'sort' => $ts['sort'], diff --git a/core/lib/Drupal/Component/Utility/UrlHelper.php b/core/lib/Drupal/Component/Utility/UrlHelper.php index cf87435..45a8036 100644 --- a/core/lib/Drupal/Component/Utility/UrlHelper.php +++ b/core/lib/Drupal/Component/Utility/UrlHelper.php @@ -134,7 +134,7 @@ public static function filterQueryParameters(array $query, array $exclude = arra * - fragment: The fragment component from $url, if it exists. * * @see \Drupal\Core\Utility\LinkGenerator - * @see url() + * @see _url() * @see http://tools.ietf.org/html/rfc3986 * * @ingroup php_wrappers @@ -288,7 +288,7 @@ public static function setAllowedProtocols(array $protocols = array()) { * to being output to an HTML attribute value. It is often called as part of * check_url() or Drupal\Component\Utility\Xss::filter(), but those functions * return an HTML-encoded string, so this function can be called independently - * when the output needs to be a plain-text string for passing to t(), l(), + * when the output needs to be a plain-text string for passing to t(), _l(), * Drupal\Core\Template\Attribute, or another function that will call * \Drupal\Component\Utility\String::checkPlain() separately. * diff --git a/core/lib/Drupal/Core/Ajax/RedirectCommand.php b/core/lib/Drupal/Core/Ajax/RedirectCommand.php index 4b0914a..4b31e52 100644 --- a/core/lib/Drupal/Core/Ajax/RedirectCommand.php +++ b/core/lib/Drupal/Core/Ajax/RedirectCommand.php @@ -28,7 +28,7 @@ class RedirectCommand implements CommandInterface { * * @param string $url * The URL that will be loaded into window.location. This should be a full - * URL, one that has already been run through the url() function. + * URL, one that has already been run through the _url() function. */ public function __construct($url) { $this->url = $url; diff --git a/core/lib/Drupal/Core/Asset/CssOptimizer.php b/core/lib/Drupal/Core/Asset/CssOptimizer.php index 1090d5a..baa2de4 100644 --- a/core/lib/Drupal/Core/Asset/CssOptimizer.php +++ b/core/lib/Drupal/Core/Asset/CssOptimizer.php @@ -119,7 +119,7 @@ public function loadFile($file, $optimize = NULL, $reset_basepath = TRUE) { * Loads stylesheets recursively and returns contents with corrected paths. * * This function is used for recursive loading of stylesheets and - * returns the stylesheet content with all url() paths corrected. + * returns the stylesheet content with all _url() paths corrected. * * @param array $matches * An array of matches by a preg_replace_callback() call that scans for @@ -138,10 +138,10 @@ protected function loadNestedFile($matches) { // Determine the file's directory. $directory = dirname($filename); // If the file is in the current directory, make sure '.' doesn't appear in - // the url() path. + // the _url() path. $directory = $directory == '.' ? '' : $directory .'/'; - // Alter all internal url() paths. Leave external paths alone. We don't need + // Alter all internal _url() paths. Leave external paths alone. We don't need // to normalize absolute paths here (i.e. remove folder/... segments) // because that will be done later. return preg_replace('/url\(\s*([\'"]?)(?![a-z]+:|\/+)([^\'")]+)([\'"]?)\s*\)/i', 'url(\1' . $directory . '\2\3)', $file); @@ -215,7 +215,7 @@ protected function processCss($contents, $optimize = FALSE) { * * @param array $matches * An array of matches by a preg_replace_callback() call that scans for - * url() references in CSS files, except for external or absolute ones. + * _url() references in CSS files, except for external or absolute ones. * * Note: the only reason this method is public is so color.module can call it; * it is not on the AssetOptimizerInterface, so future refactorings can make diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index de1d04f..07e50c7 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -192,7 +192,7 @@ public function urlInfo($rel = 'canonical', array $options = []) { } } - // Pass the entity data to url() so that alter functions do not need to + // Pass the entity data to _url() so that alter functions do not need to // look up this entity again. $uri ->setOption('entity_type', $this->getEntityTypeId()) diff --git a/core/lib/Drupal/Core/Menu/LocalTaskManager.php b/core/lib/Drupal/Core/Menu/LocalTaskManager.php index 4e1f675..3914d8e 100644 --- a/core/lib/Drupal/Core/Menu/LocalTaskManager.php +++ b/core/lib/Drupal/Core/Menu/LocalTaskManager.php @@ -250,7 +250,7 @@ public function getLocalTasksForRoute($route_name) { foreach ($children[$parent] as $plugin_id => $task_info) { $plugin = $this->createInstance($plugin_id); $this->instances[$route_name][$level][$plugin_id] = $plugin; - // Normally, l() compares the href of every link with the current + // Normally, _l() compares the href of every link with the current // path and sets the active class accordingly. But the parents of // the current local task may be on a different route in which // case we have to set the class manually by flagging it active. diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php index fb75390..2ed2fb0 100644 --- a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php @@ -1278,7 +1278,7 @@ protected static function schemaDefinition() { 'not null' => FALSE, ), 'options' => array( - 'description' => 'A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.', + 'description' => 'A serialized array of options to be passed to the _url() or _l() function, such as a query string or HTML attributes.', 'type' => 'blob', 'size' => 'big', 'not null' => FALSE, diff --git a/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php b/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php index 164f7f5..8711ee2 100644 --- a/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php +++ b/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php @@ -110,7 +110,7 @@ public function preparePage(HtmlPage $page, &$page_array) { foreach (drupal_get_feeds() as $feed) { // Force the URL to be absolute, for consistency with other tags // output by Drupal. - $link = new FeedLinkElement($feed['title'], url($feed['url'], array('absolute' => TRUE))); + $link = new FeedLinkElement($feed['title'], _url($feed['url'], array('absolute' => TRUE))); $page->addLinkElement($link); } diff --git a/core/lib/Drupal/Core/Path/AliasWhitelist.php b/core/lib/Drupal/Core/Path/AliasWhitelist.php index 394dfa2..11c68f7 100644 --- a/core/lib/Drupal/Core/Path/AliasWhitelist.php +++ b/core/lib/Drupal/Core/Path/AliasWhitelist.php @@ -88,7 +88,7 @@ protected function loadMenuPathRoots() { */ public function get($offset) { $this->lazyLoadCache(); - // url() may be called with paths that are not represented by menu router + // _url() may be called with paths that are not represented by menu router // items such as paths that will be rewritten by hook_url_outbound_alter(). // Therefore internally TRUE is used to indicate whitelisted paths. FALSE is // used to indicate paths that have already been checked but are not diff --git a/core/lib/Drupal/Core/Render/Element/Link.php b/core/lib/Drupal/Core/Render/Element/Link.php index 7e10976..474e9f5 100644 --- a/core/lib/Drupal/Core/Render/Element/Link.php +++ b/core/lib/Drupal/Core/Render/Element/Link.php @@ -34,21 +34,21 @@ public function getInfo() { * Doing so during pre_render gives modules a chance to alter the link parts. * * @param array $element - * A structured array whose keys form the arguments to l(): - * - #title: The link text to pass as argument to l(). + * A structured array whose keys form the arguments to _l(): + * - #title: The link text to pass as argument to _l(). * - One of the following * - #route_name and (optionally) a #route_parameters array; The route * name and route parameters which will be passed into the link * generator. - * - #href: The system path or URL to pass as argument to l(). - * - #options: (optional) An array of options to pass to l() or the link + * - #href: The system path or URL to pass as argument to _l(). + * - #options: (optional) An array of options to pass to _l() or the link * generator. * * @return array * The passed-in element containing a rendered link in '#markup'. */ public static function preRenderLink($element) { - // By default, link options to pass to l() are normally set in #options. + // By default, link options to pass to _l() are normally set in #options. $element += array('#options' => array()); // However, within the scope of renderable elements, #attributes is a valid // way to specify attributes, too. Take them into account, but do not override @@ -89,7 +89,7 @@ public static function preRenderLink($element) { } else { // @todo Convert to \Drupal::l(): https://www.drupal.org/node/2347045. - $element['#markup'] = l($element['#title'], $element['#href'], $element['#options']); + $element['#markup'] = _l($element['#title'], $element['#href'], $element['#options']); } return $element; } diff --git a/core/lib/Drupal/Core/Render/Element/RenderElement.php b/core/lib/Drupal/Core/Render/Element/RenderElement.php index 553496c..38e09fc 100644 --- a/core/lib/Drupal/Core/Render/Element/RenderElement.php +++ b/core/lib/Drupal/Core/Render/Element/RenderElement.php @@ -248,7 +248,7 @@ public static function preRenderAjaxForm($element) { } // Change path to URL. - $settings['url'] = isset($settings['path']) ? url($settings['path'], $settings['options']) : NULL; + $settings['url'] = isset($settings['path']) ? _url($settings['path'], $settings['options']) : NULL; unset($settings['path'], $settings['options']); // Add special data to $settings['submit'] so that when this element @@ -286,7 +286,7 @@ public static function preRenderAjaxForm($element) { } // Change progress path to a full URL. if (isset($settings['progress']['path'])) { - $settings['progress']['url'] = url($settings['progress']['path']); + $settings['progress']['url'] = _url($settings['progress']['path']); unset($settings['progress']['path']); } diff --git a/core/lib/Drupal/Core/Routing/UrlGenerator.php b/core/lib/Drupal/Core/Routing/UrlGenerator.php index 8e2522a..ae41c9c 100644 --- a/core/lib/Drupal/Core/Routing/UrlGenerator.php +++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php @@ -238,7 +238,7 @@ public function generateFromPath($path = NULL, $options = array()) { // \Drupal\Component\Utility\UrlHelper::stripDangerousProtocols() if $path // contains a ':' before any / ? or #. Note: we could use // \Drupal\Component\Utility\UrlHelper::isExternal($path) here, but that - // would require another function call, and performance inside url() is + // would require another function call, and performance inside _url() is // critical. $colonpos = strpos($path, ':'); $options['external'] = ($colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && UrlHelper::stripDangerousProtocols($path) == $path); diff --git a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php index ad58aca..06e600d 100644 --- a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php +++ b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php @@ -67,10 +67,10 @@ * - 'script': Added to the URL between the base path and the path prefix. * Defaults to empty string when clean URLs are in effect, and to * 'index.php/' when they are not. - * - 'entity_type': The entity type of the object that called url(). Only - * set if url() is invoked by Drupal\Core\Entity\Entity::uri(). + * - 'entity_type': The entity type of the object that called _url(). Only + * set if _url() is invoked by Drupal\Core\Entity\Entity::uri(). * - 'entity': The entity object (such as a node) for which the URL is being - * generated. Only set if url() is invoked by Drupal\Core\Entity\Entity::uri(). + * generated. Only set if _url() is invoked by Drupal\Core\Entity\Entity::uri(). * * @return * A string containing a URL to the given path. diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php index 20c71e6..632e42a 100644 --- a/core/lib/Drupal/Core/Template/TwigExtension.php +++ b/core/lib/Drupal/Core/Template/TwigExtension.php @@ -214,7 +214,7 @@ public function getLink($text, $url) { } else { // @todo Convert once https://www.drupal.org/node/2306901 is in - return l($text, $url); + return _l($text, $url); } } diff --git a/core/modules/aggregator/src/Tests/FeedParserTest.php b/core/modules/aggregator/src/Tests/FeedParserTest.php index 2ac0a94..a6d44c7 100644 --- a/core/modules/aggregator/src/Tests/FeedParserTest.php +++ b/core/modules/aggregator/src/Tests/FeedParserTest.php @@ -80,7 +80,7 @@ function testHtmlEntitiesSample() { */ function testRedirectFeed() { // Simulate a typo in the URL to force a curl exception. - $invalid_url = url('aggregator/redirect', array('absolute' => TRUE)); + $invalid_url = _url('aggregator/redirect', array('absolute' => TRUE)); $feed = entity_create('aggregator_feed', array('url' => $invalid_url, 'title' => $this->randomMachineName())); $feed->save(); $feed->refreshItems(); diff --git a/core/modules/aggregator/src/Tests/Views/IntegrationTest.php b/core/modules/aggregator/src/Tests/Views/IntegrationTest.php index 5084bdf..8b6edaa 100644 --- a/core/modules/aggregator/src/Tests/Views/IntegrationTest.php +++ b/core/modules/aggregator/src/Tests/Views/IntegrationTest.php @@ -107,7 +107,7 @@ public function testAggregatorItemView() { // Ensure that the rendering of the linked title works as expected. foreach ($view->result as $row) { $iid = $view->field['iid']->getValue($row); - $expected_link = l($items[$iid]->getTitle(), $items[$iid]->getLink(), array('absolute' => TRUE)); + $expected_link = _l($items[$iid]->getTitle(), $items[$iid]->getLink(), array('absolute' => TRUE)); $this->assertEqual($view->field['title']->advancedRender($row), $expected_link, 'Ensure the right link is generated'); $expected_author = aggregator_filter_xss($items[$iid]->getAuthor()); diff --git a/core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php b/core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php index 62346a1..b45105b 100644 --- a/core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php +++ b/core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php @@ -150,7 +150,7 @@ protected function basicAuthGet($path, $username, $password) { $out = $this->curlExec( array( CURLOPT_HTTPGET => TRUE, - CURLOPT_URL => url($path, array('absolute' => TRUE)), + CURLOPT_URL => _url($path, array('absolute' => TRUE)), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => $username . ':' . $password, diff --git a/core/modules/dblog/src/Controller/DbLogController.php b/core/modules/dblog/src/Controller/DbLogController.php index 4e7b974..a11fcb8 100644 --- a/core/modules/dblog/src/Controller/DbLogController.php +++ b/core/modules/dblog/src/Controller/DbLogController.php @@ -252,11 +252,11 @@ public function eventDetails($event_id) { ), array( array('data' => $this->t('Location'), 'header' => TRUE), - l($dblog->location, $dblog->location), + _l($dblog->location, $dblog->location), ), array( array('data' => $this->t('Referrer'), 'header' => TRUE), - l($dblog->referer, $dblog->referer), + _l($dblog->referer, $dblog->referer), ), array( array('data' => $this->t('Message'), 'header' => TRUE), diff --git a/core/modules/file/file.module b/core/modules/file/file.module index a516836..55f99ac 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -1589,7 +1589,7 @@ function template_preprocess_file_link(&$variables) { $options['attributes']['title'] = String::checkPlain($file_entity->getFilename()); } - $variables['link'] = l($link_text, $url, $options); + $variables['link'] = _l($link_text, $url, $options); $variables['attributes'] = array('class' => array('file')); } diff --git a/core/modules/file/src/Tests/DownloadTest.php b/core/modules/file/src/Tests/DownloadTest.php index f99f327..ac81651 100644 --- a/core/modules/file/src/Tests/DownloadTest.php +++ b/core/modules/file/src/Tests/DownloadTest.php @@ -112,8 +112,8 @@ function testFileCreateUrl() { '%C3%A9%C3%B8%C3%AF%D0%B2%CE%B2%E4%B8%AD%E5%9C%8B%E6%9B%B8%DB%9E'; // Public files should not be served by Drupal, so their URLs should not be - // generated by url(), whereas private files should be served by Drupal, so - // their URLs should be generated by url(). The difference is most apparent + // generated by _url(), whereas private files should be served by Drupal, so + // their URLs should be generated by _url(). The difference is most apparent // when $script_path is not empty (i.e., when not using clean URLs). $clean_url_settings = array( 'clean' => '', diff --git a/core/modules/filter/src/Tests/FilterDefaultConfigTest.php b/core/modules/filter/src/Tests/FilterDefaultConfigTest.php index 79a1160..5af4758 100644 --- a/core/modules/filter/src/Tests/FilterDefaultConfigTest.php +++ b/core/modules/filter/src/Tests/FilterDefaultConfigTest.php @@ -21,7 +21,7 @@ class FilterDefaultConfigTest extends DrupalUnitTestBase { protected function setUp() { parent::setUp(); - // Drupal\filter\FilterPermissions::permissions() calls into url() to output + // Drupal\filter\FilterPermissions::permissions() calls into _url() to output // a link in the description. $this->installSchema('system', 'url_alias'); diff --git a/core/modules/hal/src/Tests/DenormalizeTest.php b/core/modules/hal/src/Tests/DenormalizeTest.php index 761b804..8b5711c 100644 --- a/core/modules/hal/src/Tests/DenormalizeTest.php +++ b/core/modules/hal/src/Tests/DenormalizeTest.php @@ -24,7 +24,7 @@ public function testTypeHandling() { $data_with_valid_type = array( '_links' => array( 'type' => array( - 'href' => url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), + 'href' => _url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), ), ), ); @@ -36,10 +36,10 @@ public function testTypeHandling() { '_links' => array( 'type' => array( array( - 'href' => url('rest/types/foo', array('absolute' => TRUE)), + 'href' => _url('rest/types/foo', array('absolute' => TRUE)), ), array( - 'href' => url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), + 'href' => _url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), ), ), ), @@ -51,7 +51,7 @@ public function testTypeHandling() { $data_with_invalid_type = array( '_links' => array( 'type' => array( - 'href' => url('rest/types/foo', array('absolute' => TRUE)), + 'href' => _url('rest/types/foo', array('absolute' => TRUE)), ), ), ); @@ -84,7 +84,7 @@ public function testMarkFieldForDeletion() { $no_field_data = array( '_links' => array( 'type' => array( - 'href' => url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), + 'href' => _url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), ), ), ); @@ -94,7 +94,7 @@ public function testMarkFieldForDeletion() { $empty_field_data = array( '_links' => array( 'type' => array( - 'href' => url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), + 'href' => _url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), ), ), 'field_test_text' => array(), @@ -112,7 +112,7 @@ public function testBasicFieldDenormalization() { $data = array( '_links' => array( 'type' => array( - 'href' => url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), + 'href' => _url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), ), ), 'uuid' => array( @@ -182,7 +182,7 @@ public function testPatchDenormailzation() { $data = array( '_links' => array( 'type' => array( - 'href' => url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), + 'href' => _url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), ), ), 'field_test_text' => array( diff --git a/core/modules/hal/src/Tests/NormalizeTest.php b/core/modules/hal/src/Tests/NormalizeTest.php index 00d6687..ee40c25 100644 --- a/core/modules/hal/src/Tests/NormalizeTest.php +++ b/core/modules/hal/src/Tests/NormalizeTest.php @@ -59,8 +59,8 @@ public function testNormalize() { $entity->getTranslation('en')->set('field_test_entity_reference', array(0 => $translation_values['field_test_entity_reference'])); $entity->save(); - $type_uri = url('rest/type/entity_test/entity_test', array('absolute' => TRUE)); - $relation_uri = url('rest/relation/entity_test/entity_test/field_test_entity_reference', array('absolute' => TRUE)); + $type_uri = _url('rest/type/entity_test/entity_test', array('absolute' => TRUE)); + $relation_uri = _url('rest/relation/entity_test/entity_test/field_test_entity_reference', array('absolute' => TRUE)); $expected_array = array( '_links' => array( diff --git a/core/modules/image/image.field.inc b/core/modules/image/image.field.inc index 93ac36b..4668e26 100644 --- a/core/modules/image/image.field.inc +++ b/core/modules/image/image.field.inc @@ -86,6 +86,6 @@ function template_preprocess_image_formatter(&$variables) { if (isset($variables['path']['path'])) { $path = $variables['path']['path']; $options = isset($variables['path']['options']) ? $variables['path']['options'] : array(); - $variables['url'] = url($path, $options); + $variables['url'] = _url($path, $options); } } diff --git a/core/modules/image/src/Entity/ImageStyle.php b/core/modules/image/src/Entity/ImageStyle.php index 0579dbc..752dc1e 100644 --- a/core/modules/image/src/Entity/ImageStyle.php +++ b/core/modules/image/src/Entity/ImageStyle.php @@ -216,12 +216,12 @@ public function buildUrl($path, $clean_urls = NULL) { } // If not using clean URLs, the image derivative callback is only available - // with the script path. If the file does not exist, use url() to ensure + // with the script path. If the file does not exist, use _url() to ensure // that it is included. Once the file exists it's fine to fall back to the // actual file path, this avoids bootstrapping PHP once the files are built. if ($clean_urls === FALSE && file_uri_scheme($uri) == 'public' && !file_exists($uri)) { $directory_path = file_stream_wrapper_get_instance_by_uri($uri)->getDirectoryPath(); - return url($directory_path . '/' . file_uri_target($uri), array('absolute' => TRUE, 'query' => $token_query)); + return _url($directory_path . '/' . file_uri_target($uri), array('absolute' => TRUE, 'query' => $token_query)); } $file_url = file_create_url($uri); diff --git a/core/modules/language/src/LanguageNegotiatorInterface.php b/core/modules/language/src/LanguageNegotiatorInterface.php index c5991c2..fa46958 100644 --- a/core/modules/language/src/LanguageNegotiatorInterface.php +++ b/core/modules/language/src/LanguageNegotiatorInterface.php @@ -25,7 +25,7 @@ * - Content language: The language used to present content that is available * in more than one language. * - URL language: The language associated with URLs. When generating a URL, - * this value will be used by url() as a default if no explicit preference is + * this value will be used by _url() as a default if no explicit preference is * provided. * Modules can define additional language types through * hook_language_types_info(), and alter existing language type definitions diff --git a/core/modules/language/src/Tests/LanguageSwitchingTest.php b/core/modules/language/src/Tests/LanguageSwitchingTest.php index 9d8f7f9..dfd8d2e 100644 --- a/core/modules/language/src/Tests/LanguageSwitchingTest.php +++ b/core/modules/language/src/Tests/LanguageSwitchingTest.php @@ -185,7 +185,7 @@ protected function doTestLanguageLinkActiveClassAuthenticated() { $function_name = '#type link'; $path = 'language_test/type-link-active-class'; - // Test links generated by l() on an English page. + // Test links generated by _l() on an English page. $current_language = 'English'; $this->drupalGet($path); @@ -210,7 +210,7 @@ protected function doTestLanguageLinkActiveClassAuthenticated() { $this->assertIdentical($settings['path']['isFront'], FALSE, 'drupalSettings.path.isFront is set correctly to allow drupal.active-link to mark the correct links as active.'); $this->assertIdentical($settings['path']['currentLanguage'], 'en', 'drupalSettings.path.currentLanguage is set correctly to allow drupal.active-link to mark the correct links as active.'); - // Test links generated by l() on a French page. + // Test links generated by _l() on a French page. $current_language = 'French'; $this->drupalGet('fr/language_test/type-link-active-class'); @@ -246,7 +246,7 @@ protected function doTestLanguageLinkActiveClassAnonymous() { $this->drupalLogout(); - // Test links generated by l() on an English page. + // Test links generated by _l() on an English page. $current_language = 'English'; $this->drupalGet('language_test/type-link-active-class'); @@ -265,7 +265,7 @@ protected function doTestLanguageLinkActiveClassAnonymous() { $links = $this->xpath('//a[@id = :id and not(contains(@class, :class))]', array(':id' => 'fr_link', ':class' => 'active')); $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is NOT marked active.', array(':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode))); - // Test links generated by l() on a French page. + // Test links generated by _l() on a French page. $current_language = 'French'; $this->drupalGet('fr/language_test/type-link-active-class'); diff --git a/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php index 4753539..b1d40c0 100644 --- a/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php @@ -388,7 +388,7 @@ function testUrlLanguageFallback() { } /** - * Tests url() when separate domains are used for multiple languages. + * Tests _url() when separate domains are used for multiple languages. */ function testLanguageDomain() { // Add the Italian language. @@ -417,26 +417,26 @@ function testLanguageDomain() { // Test URL in another language: http://it.example.com/admin. // Base path gives problems on the testbot, so $correct_link is hard-coded. // @see UrlAlterFunctionalTest::assertUrlOutboundAlter (path.test). - $italian_url = url('admin', array('language' => $languages['it'], 'script' => '')); + $italian_url = _url('admin', array('language' => $languages['it'], 'script' => '')); $url_scheme = \Drupal::request()->isSecure() ? 'https://' : 'http://'; $correct_link = $url_scheme . $link; - $this->assertEqual($italian_url, $correct_link, format_string('The url() function returns the right URL (@url) in accordance with the chosen language', array('@url' => $italian_url))); + $this->assertEqual($italian_url, $correct_link, format_string('The _url() function returns the right URL (@url) in accordance with the chosen language', array('@url' => $italian_url))); // Test HTTPS via options. $this->settingsSet('mixed_mode_sessions', TRUE); $this->rebuildContainer(); - $italian_url = url('admin', array('https' => TRUE, 'language' => $languages['it'], 'script' => '')); + $italian_url = _url('admin', array('https' => TRUE, 'language' => $languages['it'], 'script' => '')); $correct_link = 'https://' . $link; - $this->assertTrue($italian_url == $correct_link, format_string('The url() function returns the right HTTPS URL (via options) (@url) in accordance with the chosen language', array('@url' => $italian_url))); + $this->assertTrue($italian_url == $correct_link, format_string('The _url() function returns the right HTTPS URL (via options) (@url) in accordance with the chosen language', array('@url' => $italian_url))); $this->settingsSet('mixed_mode_sessions', FALSE); // Test HTTPS via current URL scheme. $request = Request::create('', 'GET', array(), array(), array(), array('HTTPS' => 'on')); $this->container->get('request_stack')->push($request); $generator = $this->container->get('url_generator'); - $italian_url = url('admin', array('language' => $languages['it'], 'script' => '')); + $italian_url = _url('admin', array('language' => $languages['it'], 'script' => '')); $correct_link = 'https://' . $link; - $this->assertTrue($italian_url == $correct_link, format_string('The url() function returns the right URL (via current URL scheme) (@url) in accordance with the chosen language', array('@url' => $italian_url))); + $this->assertTrue($italian_url == $correct_link, format_string('The _url() function returns the right URL (via current URL scheme) (@url) in accordance with the chosen language', array('@url' => $italian_url))); } } diff --git a/core/modules/language/src/Tests/LanguageUrlRewritingTest.php b/core/modules/language/src/Tests/LanguageUrlRewritingTest.php index 73b54cd..ca3d935 100644 --- a/core/modules/language/src/Tests/LanguageUrlRewritingTest.php +++ b/core/modules/language/src/Tests/LanguageUrlRewritingTest.php @@ -126,7 +126,7 @@ function testDomainNameNegotiationPort() { // Create an absolute French link. $language = \Drupal::languageManager()->getLanguage('fr'); - $url = url('', array( + $url = _url('', array( 'absolute' => TRUE, 'language' => $language, )); @@ -135,8 +135,8 @@ function testDomainNameNegotiationPort() { $this->assertEqual($url, $expected, 'The right port is used.'); - // If we set the port explicitly in url(), it should not be overriden. - $url = url('', array( + // If we set the port explicitly in _url(), it should not be overriden. + $url = _url('', array( 'absolute' => TRUE, 'language' => $language, 'base_url' => $request->getBaseUrl() . ':90', diff --git a/core/modules/language/tests/language_test/src/Controller/LanguageTestController.php b/core/modules/language/tests/language_test/src/Controller/LanguageTestController.php index 8095270..2935b7d 100644 --- a/core/modules/language/tests/language_test/src/Controller/LanguageTestController.php +++ b/core/modules/language/tests/language_test/src/Controller/LanguageTestController.php @@ -53,7 +53,7 @@ public static function create(ContainerInterface $container) { /** * Returns links to the current page with different langcodes. * - * Using #type 'link' causes these links to be rendered with l(). + * Using #type 'link' causes these links to be rendered with _l(). */ public function typeLinkActiveClass() { // We assume that 'en' and 'fr' have been configured. diff --git a/core/modules/link/link.module b/core/modules/link/link.module index 0fd42d5..9207818 100644 --- a/core/modules/link/link.module +++ b/core/modules/link/link.module @@ -69,6 +69,6 @@ function template_preprocess_link_formatter_link_separate(&$variables) { $variables['link'] = \Drupal::l($variables['url_title'], $variables['url']); } else { - $variables['link'] = l($variables['url_title'], $variables['url']->getUri(), $variables['url']->getOptions()); + $variables['link'] = _l($variables['url_title'], $variables['url']->getUri(), $variables['url']->getOptions()); } } diff --git a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php index 5713eae..ca753f8 100644 --- a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php +++ b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php @@ -136,7 +136,7 @@ public function viewElements(FieldItemListInterface $items) { // If the title field value is available, use it for the link text. if (empty($settings['url_only']) && !empty($item->title)) { // Unsanitized token replacement here because $options['html'] is FALSE - // by default in l(). + // by default in _l(). $link_title = \Drupal::token()->replace($item->title, array($entity->getEntityTypeId() => $entity), array('sanitize' => FALSE, 'clear' => TRUE)); } diff --git a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkSeparateFormatter.php b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkSeparateFormatter.php index 40daa44..a32e611 100644 --- a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkSeparateFormatter.php +++ b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkSeparateFormatter.php @@ -54,7 +54,7 @@ public function viewElements(FieldItemListInterface $items) { // If the link text field value is available, use it for the text. if (empty($settings['url_only']) && !empty($item->title)) { // Unsanitized token replacement here because $options['html'] is FALSE - // by default in l(). + // by default in _l(). $link_title = \Drupal::token()->replace($item->title, array($entity->getEntityTypeId() => $entity), array('sanitize' => FALSE, 'clear' => TRUE)); } diff --git a/core/modules/link/src/Tests/LinkFieldTest.php b/core/modules/link/src/Tests/LinkFieldTest.php index a508c0c..4bd30cd 100644 --- a/core/modules/link/src/Tests/LinkFieldTest.php +++ b/core/modules/link/src/Tests/LinkFieldTest.php @@ -275,7 +275,7 @@ function testLinkTitle() { $this->assertText(t('entity_test @id has been created.', array('@id' => $id))); $this->renderTestEntity($id); - $expected_link = l($value, $value); + $expected_link = _l($value, $value); $this->assertRaw($expected_link); // Verify that a link with text is rendered using the link text. @@ -287,7 +287,7 @@ function testLinkTitle() { $this->assertText(t('entity_test @id has been updated.', array('@id' => $id))); $this->renderTestEntity($id); - $expected_link = l($title, $value); + $expected_link = _l($title, $value); $this->assertRaw($expected_link); } @@ -354,7 +354,7 @@ function testLinkFormatter() { // Verify that the link is output according to the formatter settings. // Not using generatePermutations(), since that leads to 32 cases, which // would not test actual link field formatter functionality but rather - // l() and options/attributes. Only 'url_plain' has a dependency on + // _l() and options/attributes. Only 'url_plain' has a dependency on // 'url_only', so we have a total of ~10 cases. $options = array( 'trim_length' => array(NULL, 6), diff --git a/core/modules/locale/src/Tests/LocaleUpdateBase.php b/core/modules/locale/src/Tests/LocaleUpdateBase.php index 772ac2a..5e9b81e 100644 --- a/core/modules/locale/src/Tests/LocaleUpdateBase.php +++ b/core/modules/locale/src/Tests/LocaleUpdateBase.php @@ -53,7 +53,7 @@ protected function setUp() { // Update module should not go out to d.o to check for updates. We override // the url to the default update_test xml path. But without providing // a mock xml file, no update data will be found. - \Drupal::config('update.settings')->set('fetch.url', url('update-test', array('absolute' => TRUE)))->save(); + \Drupal::config('update.settings')->set('fetch.url', _url('update-test', array('absolute' => TRUE)))->save(); // Setup timestamps to identify old and new translation sources. $this->timestampOld = REQUEST_TIME - 300; diff --git a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php index 49bc7f2..ec719c2 100644 --- a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php +++ b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php @@ -334,7 +334,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['options'] = BaseFieldDefinition::create('map') ->setLabel(t('Options')) - ->setDescription(t('A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.')) + ->setDescription(t('A serialized array of options to be passed to the _url() or _l() function, such as a query string or HTML attributes.')) ->setSetting('default_value', array()); $fields['external'] = BaseFieldDefinition::create('boolean') diff --git a/core/modules/node/src/Tests/NodeTranslationUITest.php b/core/modules/node/src/Tests/NodeTranslationUITest.php index 13eced4..b5fd27a 100644 --- a/core/modules/node/src/Tests/NodeTranslationUITest.php +++ b/core/modules/node/src/Tests/NodeTranslationUITest.php @@ -335,7 +335,7 @@ protected function doTestTranslations($path, array $values) { protected function doTestAlternateHreflangLinks($path) { $languages = $this->container->get('language_manager')->getLanguages(); foreach ($this->langcodes as $langcode) { - $urls[$langcode] = url($path, array('absolute' => TRUE, 'language' => $languages[$langcode])); + $urls[$langcode] = _url($path, array('absolute' => TRUE, 'language' => $languages[$langcode])); } foreach ($this->langcodes as $langcode) { $this->drupalGet($path, array('language' => $languages[$langcode])); diff --git a/core/modules/node/src/Tests/NodeViewTest.php b/core/modules/node/src/Tests/NodeViewTest.php index 03c0035..426fec1 100644 --- a/core/modules/node/src/Tests/NodeViewTest.php +++ b/core/modules/node/src/Tests/NodeViewTest.php @@ -24,13 +24,13 @@ public function testHtmlHeadLinks() { $this->drupalGet($node->getSystemPath()); $result = $this->xpath('//link[@rel = "version-history"]'); - $this->assertEqual($result[0]['href'], url("node/{$node->id()}/revisions")); + $this->assertEqual($result[0]['href'], _url("node/{$node->id()}/revisions")); $result = $this->xpath('//link[@rel = "edit-form"]'); - $this->assertEqual($result[0]['href'], url("node/{$node->id()}/edit")); + $this->assertEqual($result[0]['href'], _url("node/{$node->id()}/edit")); $result = $this->xpath('//link[@rel = "canonical"]'); - $this->assertEqual($result[0]['href'], url("node/{$node->id()}")); + $this->assertEqual($result[0]['href'], _url("node/{$node->id()}")); } } diff --git a/core/modules/path/src/Controller/PathController.php b/core/modules/path/src/Controller/PathController.php index 6144b67..96dd34b 100644 --- a/core/modules/path/src/Controller/PathController.php +++ b/core/modules/path/src/Controller/PathController.php @@ -73,10 +73,10 @@ public function adminOverview($keys) { $destination = drupal_get_destination(); foreach ($this->aliasStorage->getAliasesForAdminListing($header, $keys) as $data) { $row = array(); - $row['data']['alias'] = l(truncate_utf8($data->alias, 50, FALSE, TRUE), $data->source, array( + $row['data']['alias'] = _l(truncate_utf8($data->alias, 50, FALSE, TRUE), $data->source, array( 'attributes' => array('title' => $data->alias), )); - $row['data']['source'] = l(truncate_utf8($data->source, 50, FALSE, TRUE), $data->source, array( + $row['data']['source'] = _l(truncate_utf8($data->source, 50, FALSE, TRUE), $data->source, array( 'alias' => TRUE, 'attributes' => array('title' => $data->source), )); diff --git a/core/modules/path/src/Form/PathFormBase.php b/core/modules/path/src/Form/PathFormBase.php index 8564156..ecb970c 100644 --- a/core/modules/path/src/Form/PathFormBase.php +++ b/core/modules/path/src/Form/PathFormBase.php @@ -95,7 +95,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $pid = NU '#maxlength' => 255, '#size' => 45, '#description' => $this->t('Specify the existing path you wish to alias. For example: node/28, forum/1, taxonomy/term/1.'), - '#field_prefix' => url(NULL, array('absolute' => TRUE)), + '#field_prefix' => _url(NULL, array('absolute' => TRUE)), '#required' => TRUE, ); $form['alias'] = array( @@ -105,7 +105,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $pid = NU '#maxlength' => 255, '#size' => 45, '#description' => $this->t('Specify an alternative path by which this data can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'), - '#field_prefix' => url(NULL, array('absolute' => TRUE)), + '#field_prefix' => _url(NULL, array('absolute' => TRUE)), '#required' => TRUE, ); diff --git a/core/modules/path/src/Tests/PathLanguageTest.php b/core/modules/path/src/Tests/PathLanguageTest.php index d6399a0..6f1beed 100644 --- a/core/modules/path/src/Tests/PathLanguageTest.php +++ b/core/modules/path/src/Tests/PathLanguageTest.php @@ -109,7 +109,7 @@ function testAliasTranslation() { $this->drupalGet('fr/' . $edit['path[0][alias]']); $this->assertText($french_node->body->value, 'Alias for French translation works.'); - // Confirm that the alias is returned by url(). Languages are cached on + // Confirm that the alias is returned by _url(). Languages are cached on // many levels, and we need to clear those caches. $this->container->get('language_manager')->reset(); $languages = $this->container->get('language_manager')->getLanguages(); diff --git a/core/modules/responsive_image/responsive_image.module b/core/modules/responsive_image/responsive_image.module index 63c732a..8a8df92 100644 --- a/core/modules/responsive_image/responsive_image.module +++ b/core/modules/responsive_image/responsive_image.module @@ -147,7 +147,7 @@ function theme_responsive_image_formatter($variables) { $path = $variables['path']['path']; $options = isset($variables['path']['options']) ? $variables['path']['options'] : array(); $options['html'] = TRUE; - return l($responsive_image, $path, $options); + return _l($responsive_image, $path, $options); } return drupal_render($responsive_image); diff --git a/core/modules/rest/src/LinkManager/RelationLinkManager.php b/core/modules/rest/src/LinkManager/RelationLinkManager.php index 04ed8ee..f5ed9fb 100644 --- a/core/modules/rest/src/LinkManager/RelationLinkManager.php +++ b/core/modules/rest/src/LinkManager/RelationLinkManager.php @@ -44,7 +44,7 @@ public function __construct(CacheBackendInterface $cache, EntityManagerInterface */ public function getRelationUri($entity_type, $bundle, $field_name) { // @todo Make the base path configurable. - return url("rest/relation/$entity_type/$bundle/$field_name", array('absolute' => TRUE)); + return _url("rest/relation/$entity_type/$bundle/$field_name", array('absolute' => TRUE)); } /** diff --git a/core/modules/rest/src/LinkManager/TypeLinkManager.php b/core/modules/rest/src/LinkManager/TypeLinkManager.php index fb21a5f..6c37782 100644 --- a/core/modules/rest/src/LinkManager/TypeLinkManager.php +++ b/core/modules/rest/src/LinkManager/TypeLinkManager.php @@ -42,7 +42,7 @@ public function __construct(CacheBackendInterface $cache) { */ public function getTypeUri($entity_type, $bundle) { // @todo Make the base path configurable. - return url("rest/type/$entity_type/$bundle", array('absolute' => TRUE)); + return _url("rest/type/$entity_type/$bundle", array('absolute' => TRUE)); } /** diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php index c39b88f..b565cea 100644 --- a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php +++ b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php @@ -96,7 +96,7 @@ public function post(EntityInterface $entity = NULL) { $entity->save(); $this->logger->notice('Created entity %type with ID %id.', array('%type' => $entity->getEntityTypeId(), '%id' => $entity->id())); - $url = url(strtr($this->pluginId, ':', '/') . '/' . $entity->id(), array('absolute' => TRUE)); + $url = _url(strtr($this->pluginId, ':', '/') . '/' . $entity->id(), array('absolute' => TRUE)); // 201 Created responses have an empty body. return new ResourceResponse(NULL, 201, array('Location' => $url)); } diff --git a/core/modules/rest/src/Tests/AuthTest.php b/core/modules/rest/src/Tests/AuthTest.php index 257e7f1..230b24c 100644 --- a/core/modules/rest/src/Tests/AuthTest.php +++ b/core/modules/rest/src/Tests/AuthTest.php @@ -87,7 +87,7 @@ protected function basicAuthGet($path, $username, $password) { $out = $this->curlExec( array( CURLOPT_HTTPGET => TRUE, - CURLOPT_URL => url($path, array('absolute' => TRUE)), + CURLOPT_URL => _url($path, array('absolute' => TRUE)), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => $username . ':' . $password, diff --git a/core/modules/rest/src/Tests/CsrfTest.php b/core/modules/rest/src/Tests/CsrfTest.php index 9099245..84bf71f 100644 --- a/core/modules/rest/src/Tests/CsrfTest.php +++ b/core/modules/rest/src/Tests/CsrfTest.php @@ -107,7 +107,7 @@ protected function getCurlOptions() { CURLOPT_HTTPGET => FALSE, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $this->serialized, - CURLOPT_URL => url('entity/' . $this->testEntityType, array('absolute' => TRUE)), + CURLOPT_URL => _url('entity/' . $this->testEntityType, array('absolute' => TRUE)), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPHEADER => array( "Content-Type: {$this->defaultMimeType}", diff --git a/core/modules/rest/src/Tests/NodeTest.php b/core/modules/rest/src/Tests/NodeTest.php index 4cd2bc9..96619b7 100644 --- a/core/modules/rest/src/Tests/NodeTest.php +++ b/core/modules/rest/src/Tests/NodeTest.php @@ -68,7 +68,7 @@ public function testNodes() { $data = array( '_links' => array( 'type' => array( - 'href' => url('rest/type/node/resttest', array('absolute' => TRUE)), + 'href' => _url('rest/type/node/resttest', array('absolute' => TRUE)), ), ), 'title' => array( diff --git a/core/modules/rest/src/Tests/RESTTestBase.php b/core/modules/rest/src/Tests/RESTTestBase.php index a2e0ffe..32fa9c3 100644 --- a/core/modules/rest/src/Tests/RESTTestBase.php +++ b/core/modules/rest/src/Tests/RESTTestBase.php @@ -86,7 +86,7 @@ protected function httpRequest($url, $method, $body = NULL, $mime_type = NULL) { $curl_options = array( CURLOPT_HTTPGET => TRUE, CURLOPT_CUSTOMREQUEST => 'GET', - CURLOPT_URL => url($url, $options), + CURLOPT_URL => _url($url, $options), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPHEADER => array('Accept: ' . $mime_type), ); @@ -97,7 +97,7 @@ protected function httpRequest($url, $method, $body = NULL, $mime_type = NULL) { CURLOPT_HTTPGET => FALSE, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $body, - CURLOPT_URL => url($url, array('absolute' => TRUE)), + CURLOPT_URL => _url($url, array('absolute' => TRUE)), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPHEADER => array( 'Content-Type: ' . $mime_type, @@ -111,7 +111,7 @@ protected function httpRequest($url, $method, $body = NULL, $mime_type = NULL) { CURLOPT_HTTPGET => FALSE, CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_POSTFIELDS => $body, - CURLOPT_URL => url($url, array('absolute' => TRUE)), + CURLOPT_URL => _url($url, array('absolute' => TRUE)), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPHEADER => array( 'Content-Type: ' . $mime_type, @@ -125,7 +125,7 @@ protected function httpRequest($url, $method, $body = NULL, $mime_type = NULL) { CURLOPT_HTTPGET => FALSE, CURLOPT_CUSTOMREQUEST => 'PATCH', CURLOPT_POSTFIELDS => $body, - CURLOPT_URL => url($url, array('absolute' => TRUE)), + CURLOPT_URL => _url($url, array('absolute' => TRUE)), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPHEADER => array( 'Content-Type: ' . $mime_type, @@ -138,7 +138,7 @@ protected function httpRequest($url, $method, $body = NULL, $mime_type = NULL) { $curl_options = array( CURLOPT_HTTPGET => FALSE, CURLOPT_CUSTOMREQUEST => 'DELETE', - CURLOPT_URL => url($url, array('absolute' => TRUE)), + CURLOPT_URL => _url($url, array('absolute' => TRUE)), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPHEADER => array('X-CSRF-Token: ' . $token), ); diff --git a/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php b/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php index 7a145b6..e7c98c6 100644 --- a/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php +++ b/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php @@ -269,8 +269,8 @@ public function testMultipleSearchPages() { // Ensure both search pages have their tabs displayed. $this->drupalGet('search'); $elements = $this->xpath('//*[contains(@class, :class)]//a', array(':class' => 'tabs primary')); - $this->assertIdentical((string) $elements[0]['href'], url('search/' . $first['path'])); - $this->assertIdentical((string) $elements[1]['href'], url('search/' . $second['path'])); + $this->assertIdentical((string) $elements[0]['href'], _url('search/' . $first['path'])); + $this->assertIdentical((string) $elements[1]['href'], _url('search/' . $second['path'])); // Switch the weight of the search pages and check the order of the tabs. $edit = array( @@ -280,8 +280,8 @@ public function testMultipleSearchPages() { $this->drupalPostForm('admin/config/search/pages', $edit, t('Save configuration')); $this->drupalGet('search'); $elements = $this->xpath('//*[contains(@class, :class)]//a', array(':class' => 'tabs primary')); - $this->assertIdentical((string) $elements[0]['href'], url('search/' . $second['path'])); - $this->assertIdentical((string) $elements[1]['href'], url('search/' . $first['path'])); + $this->assertIdentical((string) $elements[0]['href'], _url('search/' . $second['path'])); + $this->assertIdentical((string) $elements[1]['href'], _url('search/' . $first['path'])); // Check the initial state of the search pages. $this->drupalGet('admin/config/search/pages'); diff --git a/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php b/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php index b8f7c73..d1855ad 100644 --- a/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php +++ b/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php @@ -57,7 +57,7 @@ public function execute() { } return array( array( - 'link' => url('node'), + 'link' => _url('node'), 'type' => 'Dummy result type', 'title' => 'Dummy title', 'snippet' => SafeMarkup::set("Dummy search snippet to display. Keywords: {$this->keywords}\n\nConditions: " . print_r($this->searchParameters, TRUE)), diff --git a/core/modules/serialization/src/Tests/EntityResolverTest.php b/core/modules/serialization/src/Tests/EntityResolverTest.php index 3cf8952..2bf4ed9 100644 --- a/core/modules/serialization/src/Tests/EntityResolverTest.php +++ b/core/modules/serialization/src/Tests/EntityResolverTest.php @@ -58,16 +58,16 @@ function testUuidEntityResolver() { $entity->set('field_test_entity_reference', array(array('target_id' => 1))); $entity->save(); - $field_uri = url('rest/relation/entity_test_mulrev/entity_test_mulrev/field_test_entity_reference', array('absolute' => TRUE)); + $field_uri = _url('rest/relation/entity_test_mulrev/entity_test_mulrev/field_test_entity_reference', array('absolute' => TRUE)); $data = array( '_links' => array( 'type' => array( - 'href' => url('rest/type/entity_test_mulrev/entity_test_mulrev', array('absolute' => TRUE)), + 'href' => _url('rest/type/entity_test_mulrev/entity_test_mulrev', array('absolute' => TRUE)), ), $field_uri => array( array( - 'href' => url('entity/entity_test_mulrev/' . $entity->id()), + 'href' => _url('entity/entity_test_mulrev/' . $entity->id()), ), ), ), @@ -75,7 +75,7 @@ function testUuidEntityResolver() { $field_uri => array( array( '_links' => array( - 'self' => url('entity/entity_test_mulrev/' . $entity->id()), + 'self' => _url('entity/entity_test_mulrev/' . $entity->id()), ), 'uuid' => array( array( diff --git a/core/modules/simpletest/src/TestBase.php b/core/modules/simpletest/src/TestBase.php index 171df78..b8bed09 100644 --- a/core/modules/simpletest/src/TestBase.php +++ b/core/modules/simpletest/src/TestBase.php @@ -745,7 +745,7 @@ protected function verbose($message) { $verbose_filename = $this->verboseDirectory . '/' . $this->verboseClassName . '-' . $this->verboseId . '.html'; if (file_put_contents($verbose_filename, $message, FILE_APPEND)) { $url = $this->verboseDirectoryUrl . '/' . $this->verboseClassName . '-' . $this->verboseId . '.html'; - // Not using l() to avoid invoking the theme system, so that unit tests + // Not using _l() to avoid invoking the theme system, so that unit tests // can use verbose() as well. $url = 'Verbose message'; $this->error($url, 'User notice'); diff --git a/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php b/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php index 69712c3..869dbca 100644 --- a/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php +++ b/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php @@ -77,7 +77,7 @@ public function testInternalBrowser() { // Not using File API; a potential error must trigger a PHP warning. unlink($this->siteDirectory . '/.htkey'); global $base_url; - $this->drupalGet(url($base_url . '/core/install.php', array('external' => TRUE, 'absolute' => TRUE))); + $this->drupalGet(_url($base_url . '/core/install.php', array('external' => TRUE, 'absolute' => TRUE))); $this->assertResponse(403, 'Cannot access install.php.'); } diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index ab560b2..3c826bf 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -1476,7 +1476,7 @@ protected function drupalGet($path, array $options = array(), array $headers = a * @param string $path * Path to request AJAX from. * @param array $options - * Array of options to pass to url(). + * Array of options to pass to _url(). * @param array $headers * Array of headers. Eg array('Accept: application/vnd.drupal-ajax'). * @@ -1925,11 +1925,11 @@ protected function drupalProcessAjaxResponse($content, array $ajax_response, arr * * @see WebTestBase::getAjaxPageStatePostData() * @see WebTestBase::curlExec() - * @see url() + * @see _url() */ protected function drupalPost($path, $accept, array $post, $options = array()) { return $this->curlExec(array( - CURLOPT_URL => url($path, $options + array('absolute' => TRUE)), + CURLOPT_URL => _url($path, $options + array('absolute' => TRUE)), CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $this->serializePostValues($post), CURLOPT_HTTPHEADER => array( diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module index 3c80cd8..00ca78d 100644 --- a/core/modules/statistics/statistics.module +++ b/core/modules/statistics/statistics.module @@ -39,7 +39,7 @@ function statistics_help($route_name, RouteMatchInterface $route_match) { function statistics_node_view(array &$build, EntityInterface $node, EntityViewDisplayInterface $display, $view_mode) { if (!$node->isNew() && $view_mode == 'full' && node_is_page($node) && empty($node->in_preview)) { $build['statistics_content_counter']['#attached']['library'][] = 'statistics/drupal.statistics'; - $settings = array('data' => array('nid' => $node->id()), 'url' => url(drupal_get_path('module', 'statistics') . '/statistics.php')); + $settings = array('data' => array('nid' => $node->id()), 'url' => _url(drupal_get_path('module', 'statistics') . '/statistics.php')); $build['statistics_content_counter']['#attached']['js'][] = array( 'data' => array('statistics' => $settings), 'type' => 'setting', diff --git a/core/modules/system/language.api.php b/core/modules/system/language.api.php index 3a74f82..f52e22d 100644 --- a/core/modules/system/language.api.php +++ b/core/modules/system/language.api.php @@ -95,7 +95,7 @@ * Perform alterations on language switcher links. * * A language switcher link may need to point to a different path or use a - * translated link text before going through l(), which will just handle the + * translated link text before going through _l(), which will just handle the * path aliases. * * @param $links diff --git a/core/modules/system/src/Form/SiteInformationForm.php b/core/modules/system/src/Form/SiteInformationForm.php index d8328df..7ae14cf 100644 --- a/core/modules/system/src/Form/SiteInformationForm.php +++ b/core/modules/system/src/Form/SiteInformationForm.php @@ -114,7 +114,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#default_value' => $front_page, '#size' => 40, '#description' => t('Optionally, specify a relative URL to display as the front page. Leave blank to display the default front page.'), - '#field_prefix' => url(NULL, array('absolute' => TRUE)), + '#field_prefix' => _url(NULL, array('absolute' => TRUE)), ); $form['error_page'] = array( '#type' => 'details', @@ -127,7 +127,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#default_value' => $site_config->get('page.403'), '#size' => 40, '#description' => t('This page is displayed when the requested document is denied to the current user. Leave blank to display a generic "access denied" page.'), - '#field_prefix' => url(NULL, array('absolute' => TRUE)), + '#field_prefix' => _url(NULL, array('absolute' => TRUE)), ); $form['error_page']['site_404'] = array( '#type' => 'textfield', @@ -135,7 +135,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#default_value' => $site_config->get('page.404'), '#size' => 40, '#description' => t('This page is displayed when no other content matches the requested document. Leave blank to display a generic "page not found" page.'), - '#field_prefix' => url(NULL, array('absolute' => TRUE)), + '#field_prefix' => _url(NULL, array('absolute' => TRUE)), ); return parent::buildForm($form, $form_state); diff --git a/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php b/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php index 4b4e222..7efb671 100644 --- a/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php +++ b/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php @@ -149,7 +149,7 @@ protected function verifyPageCacheTags($path, $expected_tags) { sort($actual_tags); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT'); $this->assertIdentical($actual_tags, $expected_tags); - $cid_parts = array(url($path, array('absolute' => TRUE)), 'html'); + $cid_parts = array(_url($path, array('absolute' => TRUE)), 'html'); $cid = sha1(implode(':', $cid_parts)); $cache_entry = \Drupal::cache('render')->get($cid); sort($cache_entry->tags); diff --git a/core/modules/system/src/Tests/Cache/PageCacheTagsTestBase.php b/core/modules/system/src/Tests/Cache/PageCacheTagsTestBase.php index f3a0d76..e54f97b 100644 --- a/core/modules/system/src/Tests/Cache/PageCacheTagsTestBase.php +++ b/core/modules/system/src/Tests/Cache/PageCacheTagsTestBase.php @@ -46,7 +46,7 @@ protected function verifyPageCache($path, $hit_or_miss, $tags = FALSE) { $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), $hit_or_miss, $message); if ($hit_or_miss === 'HIT' && is_array($tags)) { - $cid_parts = array(url($path, array('absolute' => TRUE)), 'html'); + $cid_parts = array(_url($path, array('absolute' => TRUE)), 'html'); $cid = sha1(implode(':', $cid_parts)); $cache_entry = \Drupal::cache('render')->get($cid); sort($cache_entry->tags); diff --git a/core/modules/system/src/Tests/Common/AddFeedTest.php b/core/modules/system/src/Tests/Common/AddFeedTest.php index 8de6090..a24581d 100644 --- a/core/modules/system/src/Tests/Common/AddFeedTest.php +++ b/core/modules/system/src/Tests/Common/AddFeedTest.php @@ -23,11 +23,11 @@ class AddFeedTest extends WebTestBase { function testBasicFeedAddNoTitle() { $path = $this->randomMachineName(12); $external_url = 'http://' . $this->randomMachineName(12) . '/' . $this->randomMachineName(12); - $fully_qualified_local_url = url($this->randomMachineName(12), array('absolute' => TRUE)); + $fully_qualified_local_url = _url($this->randomMachineName(12), array('absolute' => TRUE)); $path_for_title = $this->randomMachineName(12); $external_for_title = 'http://' . $this->randomMachineName(12) . '/' . $this->randomMachineName(12); - $fully_qualified_for_title = url($this->randomMachineName(12), array('absolute' => TRUE)); + $fully_qualified_for_title = _url($this->randomMachineName(12), array('absolute' => TRUE)); // Possible permutations of drupal_add_feed() to test. // - 'input_url': the path passed to drupal_add_feed(), @@ -35,7 +35,7 @@ function testBasicFeedAddNoTitle() { // - 'title' == the title of the feed as passed into drupal_add_feed(). $urls = array( 'path without title' => array( - 'url' => url($path, array('absolute' => TRUE)), + 'url' => _url($path, array('absolute' => TRUE)), 'title' => '', ), 'external URL without title' => array( @@ -47,7 +47,7 @@ function testBasicFeedAddNoTitle() { 'title' => '', ), 'path with title' => array( - 'url' => url($path_for_title, array('absolute' => TRUE)), + 'url' => _url($path_for_title, array('absolute' => TRUE)), 'title' => $this->randomMachineName(12), ), 'external URL with title' => array( diff --git a/core/modules/system/src/Tests/Common/RenderElementTypesTest.php b/core/modules/system/src/Tests/Common/RenderElementTypesTest.php index 6d83838..9757a2b 100644 --- a/core/modules/system/src/Tests/Common/RenderElementTypesTest.php +++ b/core/modules/system/src/Tests/Common/RenderElementTypesTest.php @@ -147,7 +147,7 @@ function testMoreLink() { '#type' => 'more_link', '#href' => 'a/link', ), - 'expected' => '//div[@class="more-link"]/a[@href="' . url('a/link') . '" and text()="More"]', + 'expected' => '//div[@class="more-link"]/a[@href="' . _url('a/link') . '" and text()="More"]', ), array( 'name' => "#type 'more_link' anchor tag with a route", @@ -165,7 +165,7 @@ function testMoreLink() { '#href' => 'admin/content', '#options' => array('absolute' => TRUE), ), - 'expected' => '//div[@class="more-link"]/a[@href="' . url('admin/content', array('absolute' => TRUE)) . '" and text()="More"]', + 'expected' => '//div[@class="more-link"]/a[@href="' . _url('admin/content', array('absolute' => TRUE)) . '" and text()="More"]', ), array( 'name' => "#type 'more_link' anchor tag to the front page", @@ -173,7 +173,7 @@ function testMoreLink() { '#type' => 'more_link', '#href' => '', ), - 'expected' => '//div[@class="more-link"]/a[@href="' . url('') . '" and text()="More"]', + 'expected' => '//div[@class="more-link"]/a[@href="' . _url('') . '" and text()="More"]', ), ); diff --git a/core/modules/system/src/Tests/Common/RenderWebTest.php b/core/modules/system/src/Tests/Common/RenderWebTest.php index 3c8725a..3e58fb0 100644 --- a/core/modules/system/src/Tests/Common/RenderWebTest.php +++ b/core/modules/system/src/Tests/Common/RenderWebTest.php @@ -111,7 +111,7 @@ function testDrupalRenderFormElements() { ), ); $this->assertRenderedElement($element, '//a[@href=:href and contains(., :title)]', array( - ':href' => url($element['#href'], array('absolute' => TRUE)), + ':href' => _url($element['#href'], array('absolute' => TRUE)), ':title' => $element['#title'], )); diff --git a/core/modules/system/src/Tests/Common/UrlTest.php b/core/modules/system/src/Tests/Common/UrlTest.php index 4edae14..0097512 100644 --- a/core/modules/system/src/Tests/Common/UrlTest.php +++ b/core/modules/system/src/Tests/Common/UrlTest.php @@ -12,12 +12,12 @@ use Drupal\simpletest\WebTestBase; /** - * Confirm that url(), + * Confirm that _url(), * \Drupal\Component\Utility\UrlHelper::filterQueryParameters(), - * \Drupal\Component\Utility\UrlHelper::buildQuery(), and l() work correctly + * \Drupal\Component\Utility\UrlHelper::buildQuery(), and _l() work correctly * with various input. * - * url() calls \Drupal::moduleHandler()->getImplementations(), + * _url() calls \Drupal::moduleHandler()->getImplementations(), * which may issue a db query, which requires * inheriting from a web test case rather than a unit test case. * @@ -31,12 +31,12 @@ class UrlTest extends WebTestBase { * Confirms that invalid URLs are filtered in link generating functions. */ function testLinkXSS() { - // Test l(). + // Test _l(). $text = $this->randomMachineName(); $path = ""; - $link = l($text, $path); - $sanitized_path = check_url(url($path)); - $this->assertTrue(strpos($link, $sanitized_path) !== FALSE, format_string('XSS attack @path was filtered by l().', array('@path' => $path))); + $link = _l($text, $path); + $sanitized_path = check_url(_url($path)); + $this->assertTrue(strpos($link, $sanitized_path) !== FALSE, format_string('XSS attack @path was filtered by _l().', array('@path' => $path))); // Test #type 'link'. $link_array = array( @@ -45,7 +45,7 @@ function testLinkXSS() { '#href' => $path, ); $type_link = drupal_render($link_array); - $sanitized_path = check_url(url($path)); + $sanitized_path = check_url(_url($path)); $this->assertTrue(strpos($type_link, $sanitized_path) !== FALSE, format_string('XSS attack @path was filtered by #theme', array('@path' => $path))); } @@ -76,7 +76,7 @@ function testLinkAttributes() { $rendered = drupal_render($hreflang_override_link); $this->assertTrue($this->hasAttribute('hreflang', $rendered, 'foo'), format_string('hreflang attribute with value @hreflang is present on a rendered link when @hreflang is provided in the render array.', array('@hreflang' => 'foo'))); - // Test the active class in links produced by l() and #type 'link'. + // Test the active class in links produced by _l() and #type 'link'. $options_no_query = array(); $options_query = array( 'query' => array( @@ -95,27 +95,27 @@ function testLinkAttributes() { $path = 'common-test/type-link-active-class'; $this->drupalGet($path, $options_no_query); - $links = $this->xpath('//a[@href = :href and contains(@class, :class)]', array(':href' => url($path, $options_no_query), ':class' => 'active')); - $this->assertTrue(isset($links[0]), 'A link generated by l() to the current page is marked active.'); + $links = $this->xpath('//a[@href = :href and contains(@class, :class)]', array(':href' => _url($path, $options_no_query), ':class' => 'active')); + $this->assertTrue(isset($links[0]), 'A link generated by _l() to the current page is marked active.'); - $links = $this->xpath('//a[@href = :href and not(contains(@class, :class))]', array(':href' => url($path, $options_query), ':class' => 'active')); - $this->assertTrue(isset($links[0]), 'A link generated by l() to the current page with a query string when the current page has no query string is not marked active.'); + $links = $this->xpath('//a[@href = :href and not(contains(@class, :class))]', array(':href' => _url($path, $options_query), ':class' => 'active')); + $this->assertTrue(isset($links[0]), 'A link generated by _l() to the current page with a query string when the current page has no query string is not marked active.'); $this->drupalGet($path, $options_query); - $links = $this->xpath('//a[@href = :href and contains(@class, :class)]', array(':href' => url($path, $options_query), ':class' => 'active')); - $this->assertTrue(isset($links[0]), 'A link generated by l() to the current page with a query string that matches the current query string is marked active.'); + $links = $this->xpath('//a[@href = :href and contains(@class, :class)]', array(':href' => _url($path, $options_query), ':class' => 'active')); + $this->assertTrue(isset($links[0]), 'A link generated by _l() to the current page with a query string that matches the current query string is marked active.'); - $links = $this->xpath('//a[@href = :href and contains(@class, :class)]', array(':href' => url($path, $options_query_reverse), ':class' => 'active')); - $this->assertTrue(isset($links[0]), 'A link generated by l() to the current page with a query string that has matching parameters to the current query string but in a different order is marked active.'); + $links = $this->xpath('//a[@href = :href and contains(@class, :class)]', array(':href' => _url($path, $options_query_reverse), ':class' => 'active')); + $this->assertTrue(isset($links[0]), 'A link generated by _l() to the current page with a query string that has matching parameters to the current query string but in a different order is marked active.'); - $links = $this->xpath('//a[@href = :href and not(contains(@class, :class))]', array(':href' => url($path, $options_no_query), ':class' => 'active')); - $this->assertTrue(isset($links[0]), 'A link generated by l() to the current page without a query string when the current page has a query string is not marked active.'); + $links = $this->xpath('//a[@href = :href and not(contains(@class, :class))]', array(':href' => _url($path, $options_no_query), ':class' => 'active')); + $this->assertTrue(isset($links[0]), 'A link generated by _l() to the current page without a query string when the current page has a query string is not marked active.'); - // Test adding a custom class in links produced by l() and #type 'link'. - // Test l(). + // Test adding a custom class in links produced by _l() and #type 'link'. + // Test _l(). $class_l = $this->randomMachineName(); - $link_l = l($this->randomMachineName(), current_path(), array('attributes' => array('class' => array($class_l)))); - $this->assertTrue($this->hasAttribute('class', $link_l, $class_l), format_string('Custom class @class is present on link when requested by l()', array('@class' => $class_l))); + $link_l = _l($this->randomMachineName(), current_path(), array('attributes' => array('class' => array($class_l)))); + $this->assertTrue($this->hasAttribute('class', $link_l, $class_l), format_string('Custom class @class is present on link when requested by _l()', array('@class' => $class_l))); // Test #type. $class_theme = $this->randomMachineName(); @@ -137,12 +137,12 @@ function testLinkAttributes() { * Tests that link functions support render arrays as 'text'. */ function testLinkRenderArrayText() { - // Build a link with l() for reference. - $l = l('foo', 'http://drupal.org'); + // Build a link with _l() for reference. + $l = _l('foo', 'http://drupal.org'); - // Test a renderable array passed to l(). + // Test a renderable array passed to _l(). $renderable_text = array('#markup' => 'foo'); - $l_renderable_text = l($renderable_text, 'http://drupal.org'); + $l_renderable_text = _l($renderable_text, 'http://drupal.org'); $this->assertEqual($l_renderable_text, $l); // Test a themed link with plain text 'text'. @@ -261,30 +261,30 @@ function testExternalUrls() { // Verify external URL can contain a fragment. $url = $test_url . '#drupal'; - $result = url($url); + $result = _url($url); $this->assertEqual($url, $result, 'External URL with fragment works without a fragment in $options.'); // Verify fragment can be overidden in an external URL. $url = $test_url . '#drupal'; $fragment = $this->randomMachineName(10); - $result = url($url, array('fragment' => $fragment)); + $result = _url($url, array('fragment' => $fragment)); $this->assertEqual($test_url . '#' . $fragment, $result, 'External URL fragment is overidden with a custom fragment in $options.'); // Verify external URL can contain a query string. $url = $test_url . '?drupal=awesome'; - $result = url($url); + $result = _url($url); $this->assertEqual($url, $result, 'External URL with query string works without a query string in $options.'); // Verify external URL can be extended with a query string. $url = $test_url; $query = array($this->randomMachineName(5) => $this->randomMachineName(5)); - $result = url($url, array('query' => $query)); + $result = _url($url, array('query' => $query)); $this->assertEqual($url . '?' . http_build_query($query, '', '&'), $result, 'External URL can be extended with a query string in $options.'); // Verify query string can be extended in an external URL. $url = $test_url . '?drupal=awesome'; $query = array($this->randomMachineName(5) => $this->randomMachineName(5)); - $result = url($url, array('query' => $query)); + $result = _url($url, array('query' => $query)); $this->assertEqual($url . '&' . http_build_query($query, '', '&'), $result, 'External URL query string can be extended with a custom query string in $options.'); } } diff --git a/core/modules/system/src/Tests/Form/RebuildTest.php b/core/modules/system/src/Tests/Form/RebuildTest.php index 7affa60..a1d4ac2 100644 --- a/core/modules/system/src/Tests/Form/RebuildTest.php +++ b/core/modules/system/src/Tests/Form/RebuildTest.php @@ -105,6 +105,6 @@ function testPreserveFormActionAfterAJAX() { // Ensure that the form's action is correct. $forms = $this->xpath('//form[contains(@class, "node-page-form")]'); - $this->assert(count($forms) == 1 && $forms[0]['action'] == url('node/add/page'), 'Re-rendered form contains the correct action value.'); + $this->assert(count($forms) == 1 && $forms[0]['action'] == _url('node/add/page'), 'Re-rendered form contains the correct action value.'); } } diff --git a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php index cf5ab1a..d5d7250 100644 --- a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php +++ b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php @@ -280,7 +280,7 @@ function testBreadCrumbs() { // other than the breadcrumb trail. $elements = $this->xpath('//nav[@id=:menu]/descendant::a[@href=:href]', array( ':menu' => 'block-bartik-tools', - ':href' => url($link_path), + ':href' => _url($link_path), )); $this->assertTrue(count($elements) == 1, "Link to {$link_path} appears only once."); diff --git a/core/modules/system/src/Tests/Menu/LocalActionTest.php b/core/modules/system/src/Tests/Menu/LocalActionTest.php index bcc443b..3c02aad 100644 --- a/core/modules/system/src/Tests/Menu/LocalActionTest.php +++ b/core/modules/system/src/Tests/Menu/LocalActionTest.php @@ -48,7 +48,7 @@ protected function assertLocalAction(array $actions) { $index = 0; foreach ($actions as $href => $title) { $this->assertEqual((string) $elements[$index], $title); - $this->assertEqual($elements[$index]['href'], url($href)); + $this->assertEqual($elements[$index]['href'], _url($href)); $index++; } } diff --git a/core/modules/system/src/Tests/Menu/LocalTasksTest.php b/core/modules/system/src/Tests/Menu/LocalTasksTest.php index 957e2eb..fc61315 100644 --- a/core/modules/system/src/Tests/Menu/LocalTasksTest.php +++ b/core/modules/system/src/Tests/Menu/LocalTasksTest.php @@ -34,7 +34,7 @@ protected function assertLocalTasks(array $hrefs, $level = 0) { )); $this->assertTrue(count($elements), 'Local tasks found.'); foreach ($hrefs as $index => $element) { - $expected = url($hrefs[$index]); + $expected = _url($hrefs[$index]); $method = ($elements[$index]['href'] == $expected ? 'pass' : 'fail'); $this->{$method}(format_string('Task @number href @value equals @expected.', array( '@number' => $index + 1, diff --git a/core/modules/system/src/Tests/Menu/MenuRouterTest.php b/core/modules/system/src/Tests/Menu/MenuRouterTest.php index 89a6a32..48c7500 100644 --- a/core/modules/system/src/Tests/Menu/MenuRouterTest.php +++ b/core/modules/system/src/Tests/Menu/MenuRouterTest.php @@ -70,8 +70,8 @@ protected function doTestHookMenuIntegration() { $this->assertLink('Local task A'); $this->assertLink('Local task B'); // Confirm correct local task href. - $this->assertLinkByHref(url($base_path)); - $this->assertLinkByHref(url($base_path . '/b')); + $this->assertLinkByHref(_url($base_path)); + $this->assertLinkByHref(_url($base_path . '/b')); } /** diff --git a/core/modules/system/src/Tests/Menu/MenuTestBase.php b/core/modules/system/src/Tests/Menu/MenuTestBase.php index fc896d8..2478af3 100644 --- a/core/modules/system/src/Tests/Menu/MenuTestBase.php +++ b/core/modules/system/src/Tests/Menu/MenuTestBase.php @@ -64,7 +64,7 @@ protected function assertBreadcrumbParts($trail) { // this test would go into an infinite loop, so we need to check that too. while ($trail && !empty($parts)) { foreach ($trail as $path => $title) { - $url = url($path); + $url = _url($path); $part = array_shift($parts); $pass = ($pass && $part['href'] === $url && $part['text'] === String::checkPlain($title)); } @@ -101,7 +101,7 @@ protected function assertMenuActiveTrail($tree, $last_active) { $part_xpath .= 'li[contains(@class, :class)]/a[contains(@href, :href) and contains(text(), :title)]'; $part_args = array( ':class' => 'active-trail', - ':href' => url($link_path), + ':href' => _url($link_path), ':title' => $link_title, ); $xpath .= $this->buildXPathQuery($part_xpath, $part_args); @@ -121,7 +121,7 @@ protected function assertMenuActiveTrail($tree, $last_active) { $args = array( ':class-trail' => 'active-trail', ':class-active' => 'active', - ':href' => url($active_link_path), + ':href' => _url($active_link_path), ':title' => $active_link_title, ); $elements = $this->xpath($xpath, $args); diff --git a/core/modules/system/src/Tests/Menu/MenuTranslateTest.php b/core/modules/system/src/Tests/Menu/MenuTranslateTest.php index 99e1401..ea4b302 100644 --- a/core/modules/system/src/Tests/Menu/MenuTranslateTest.php +++ b/core/modules/system/src/Tests/Menu/MenuTranslateTest.php @@ -40,7 +40,7 @@ public function testMenuTranslate() { $this->assertResponse(403); $elements = $this->xpath('//ul[@class=:class]/li/a[@href=:href]', array( ':class' => 'tabs primary', - ':href' => url('foo/asdf'), + ':href' => _url('foo/asdf'), )); $this->assertTrue(empty($elements), 'No tab linking to foo/asdf found'); $this->assertNoLinkByHref('foo/asdf/b'); diff --git a/core/modules/system/src/Tests/Path/UrlAlterFunctionalTest.php b/core/modules/system/src/Tests/Path/UrlAlterFunctionalTest.php index 6f81d0d..7f64ddb 100644 --- a/core/modules/system/src/Tests/Path/UrlAlterFunctionalTest.php +++ b/core/modules/system/src/Tests/Path/UrlAlterFunctionalTest.php @@ -87,9 +87,9 @@ function testCurrentUrlRequestedPath() { * Assert that an outbound path is altered to an expected value. * * @param $original - * A string with the original path that is run through url(). + * A string with the original path that is run through _url(). * @param $final - * A string with the expected result after url(). + * A string with the expected result after _url(). * @return * TRUE if $original was correctly altered to $final, FALSE otherwise. */ @@ -107,7 +107,7 @@ protected function assertUrlOutboundAlter($original, $final) { * @param $original * The original path before it has been altered by inbound URL processing. * @param $final - * A string with the expected result after url(). + * A string with the expected result after _url(). * @return * TRUE if $original was correctly altered to $final, FALSE otherwise. */ diff --git a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php index 2152474..eaed0a6 100644 --- a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php +++ b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php @@ -74,7 +74,7 @@ public function testClear() { * Tests the generation of all system site information tokens. */ public function testSystemSiteTokenReplacement() { - // The use of the url() function requires the url_alias table to exist. + // The use of the _url() function requires the url_alias table to exist. $this->installSchema('system', 'url_alias'); $url_options = array( 'absolute' => TRUE, diff --git a/core/modules/system/src/Tests/Theme/FunctionsTest.php b/core/modules/system/src/Tests/Theme/FunctionsTest.php index c970553..c8d068c 100644 --- a/core/modules/system/src/Tests/Theme/FunctionsTest.php +++ b/core/modules/system/src/Tests/Theme/FunctionsTest.php @@ -170,7 +170,7 @@ function testItemList() { * Tests links.html.twig. */ function testLinks() { - // Turn off the query for the l() function to compare the active + // Turn off the query for the _l() function to compare the active // link correctly. $original_query = \Drupal::request()->query->all(); \Drupal::request()->query->replace(array()); @@ -216,9 +216,9 @@ function testLinks() { $expected_links = ''; $expected_links .= '