Commit 002ae719 authored by alexpott's avatar alexpott

Issue #2343661 by larowlan, tim.plunkett | xjm: Rename l() to _l() and url()...

Issue #2343661 by larowlan, tim.plunkett | xjm: Rename l() to _l() and url() to _url(), and document replacements.
parent 31022924
......@@ -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']),
));
......
......@@ -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. URIs
* from the same sub-domain that are not handled by Drupal controllers should
* be prepended with 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. URIs
* from the same sub-domain that are not handled by Drupal controllers should
* be prepended with 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_url);
* $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.
......
......@@ -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 <a href="@error_url">the error page</a>', array('@error_url' => url($url, array('query' => array('id' => $batch['id'], 'op' => 'finished')))));
$batch['error_message'] = t('Please continue to <a href="@error_url">the error page</a>', 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 {
......
......@@ -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];
}
......
......@@ -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'],
......
......@@ -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.
*
......
......@@ -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;
......
......@@ -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
......
......@@ -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())
......
......@@ -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.
......
......@@ -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,
......
......@@ -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 <link> 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);
}
......
......@@ -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
......
......@@ -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;
}
......
......@@ -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']);
}
......
......@@ -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);
......
......@@ -67,10 +67,10 @@ interface UrlGeneratorInterface extends VersatileGeneratorInterface {
* - '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.
......
......@@ -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);
}
}
......
......@@ -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();
......
......@@ -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());
......
......@@ -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,
......
......@@ -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),
......
......@@ -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'));
}
......
......@@ -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' => '',
......
......@@ -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');
......
......@@ -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(
......
......@@ -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(
......
......@@ -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);
}
}
......@@ -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);
......
......@@ -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
......
......@@ -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');
......
......@@ -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)));
}
}
......@@ -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',
......
......@@ -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.
......
......@@ -69,6 +69,6 @@ function template_preprocess_link_formatter_link_separate(&$variables) {
$variables['link'] = \Drupal::l($variables['url_title'