Return the current URL path of the page being viewed.
Examples:
This function is not available in hook_boot() so use request_path() instead. However, be careful when doing that because in the case of Example #3 request_path() will contain "path/alias". If "node/306" is needed, calling drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL) makes this function available.
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')) {
return drupal_container()
->get('request')->attributes
->get('system_path');
}
// If we are outside the request scope, fall back to using the path stored in
// _current_path().
return _current_path();
}