Return the current URL path of the page being viewed.
Examples:
This function is available only after DRUPAL_BOOTSTRAP_FULL.
The current Drupal URL path.
function current_path() {
// @todo Remove the check for whether the request service exists and the
// fallback code below, once the path alias logic has been figured out in
// http://drupal.org/node/1269742.
if (drupal_container()
->isScopeActive('request')) {
$path = drupal_container()
->get('request')->attributes
->get('system_path');
if ($path !== NULL) {
return $path;
}
}
// If we are outside the request scope, fall back to using the path stored in
// _current_path().
return _current_path();
}