Skip to content

Instantly share code, notes, and snippets.

@GoZOo
Created October 18, 2018 15:17
Show Gist options
  • Save GoZOo/6e484f4e3001242a91922a63cc4195cd to your computer and use it in GitHub Desktop.
Save GoZOo/6e484f4e3001242a91922a63cc4195cd to your computer and use it in GitHub Desktop.
Drupal 8 - Get route name and parameters from url
// Launch this thanks to /devel/php in your development environment.
$current_path = '/admin/config/';
$url_object = \Drupal::service('path.validator')->getUrlIfValid($current_path);
$route_name = $url_object->getRouteName();
$route_parameters = $url_object->getrouteParameters();
dpm($route_name);
dpm($route_parameters);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment