Skip to content

Instantly share code, notes, and snippets.

@init90
Last active May 5, 2018 21:38
Show Gist options
  • Save init90/05d79583d83c0ef0bfa774e4538a555b to your computer and use it in GitHub Desktop.
Save init90/05d79583d83c0ef0bfa774e4538a555b to your computer and use it in GitHub Desktop.
Drupal 8, get route name by url.
$url = 'url';
$url_object = \Drupal::service('path.validator')->getUrlIfValid($url);
$route = $url_object->getRouteName();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment