drupal 8 get current route parameters code example
Example 1: drupal 8 routing parameters
example.user:
path: '/example/{user}'
defaults:
_controller: '\Drupal\example\Controller\ExampleController::content'
requirements:
_permission: 'access content'
options:
parameters:
user:
type: entity:user
Example 2: drupal 8 get route name
$route_name = \Drupal::routeMatch()->getRouteName();
Example 3: drupal8 get params from route
if ($node = \Drupal::routeMatch()->getParameter('node')) {
}