By acbramley on
Change record status:
Draft (View all draft change records)
Project:
Introduced in branch:
11.x
Introduced in version:
11.3.0
Issue links:
Description:
To better support deprecated and aliased routes, a new isRouteName method has been added to the current_route_match service.
It is strongly advised to use this new method when comparing route names as it will take into account deprecated or aliased routes.
For example, it is quite common to do something like this to compare the current route name:
if (\Drupal::routeMatch()->getRouteName() === 'foo.route') {
// Some special logic for the route.
}
However, if foo.route was ever aliased and/or deprecated this code would no longer work. Using the new method will better cover these scenarios:
if (\Drupal::routeMatch()->isRouteName('foo.route')) {
// Some special logic for the route.
}
Impacts:
Module developers