Current Url
$current_url = Url::fromRoute('<current>');
$path = $current_url->toString();
Current Url : Internal Path / Route Name
$current_url->toString(); # /en/user/login
$current_url->getInternalPath(); # user/login
$path = $current_url->getRouteName(); # <current>
System Path
$path = \Drupal::request()->attributes->get('_system_path');
Current Uri
$current_uri_with_query_string = \Drupal::request()->getRequestUri();
Current Path : Alias by Path
$current_path = \Drupal::service('path.current')->getPath();
$alias_by_path = \Drupal::service('path.alias_manager')->getAliasByPath($current_path);
Neuen Kommentar schreiben