Issue #2426457 by alexpott: Remove request_path
parent
0d15b2b5eb
commit
4fe82dea6e
|
@ -1014,54 +1014,6 @@ function language_default() {
|
||||||
return \Drupal::languageManager()->getDefaultLanguage();
|
return \Drupal::languageManager()->getDefaultLanguage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the requested URL path of the page being viewed.
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* - http://example.com/node/306 returns "node/306".
|
|
||||||
* - http://example.com/drupalfolder/node/306 returns "node/306" while
|
|
||||||
* base_path() returns "/drupalfolder/".
|
|
||||||
* - http://example.com/path/alias (which is a path alias for node/306) returns
|
|
||||||
* "path/alias" as opposed to the internal path.
|
|
||||||
* - http://example.com/index.php returns an empty string (meaning: front page).
|
|
||||||
* - http://example.com/index.php?page=1 returns an empty string.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* The requested Drupal URL path.
|
|
||||||
*/
|
|
||||||
function request_path() {
|
|
||||||
static $path;
|
|
||||||
|
|
||||||
if (isset($path)) {
|
|
||||||
return $path;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the part of the URI between the base path of the Drupal installation
|
|
||||||
// and the query string, and unescape it.
|
|
||||||
$request_path = request_uri(TRUE);
|
|
||||||
$base_path_len = strlen(rtrim(dirname($_SERVER['SCRIPT_NAME']), '\/'));
|
|
||||||
$path = substr(urldecode($request_path), $base_path_len + 1);
|
|
||||||
|
|
||||||
// Depending on server configuration, the URI might or might not include the
|
|
||||||
// script name. For example, the front page might be accessed as
|
|
||||||
// http://example.com or as http://example.com/index.php, and the "user"
|
|
||||||
// page might be accessed as http://example.com/user or as
|
|
||||||
// http://example.com/index.php/user. Strip the script name from $path.
|
|
||||||
$script = basename($_SERVER['SCRIPT_NAME']);
|
|
||||||
if ($path == $script) {
|
|
||||||
$path = '';
|
|
||||||
}
|
|
||||||
elseif (strpos($path, $script . '/') === 0) {
|
|
||||||
$path = substr($path, strlen($script) + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extra slashes can appear in URLs or under some conditions, added by Apache,
|
|
||||||
// so normalize.
|
|
||||||
$path = trim($path, '/');
|
|
||||||
|
|
||||||
return $path;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an additional namespace.
|
* Registers an additional namespace.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue