function LocalTaskManager::isRouteActive
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Menu/LocalTaskManager.php \Drupal\Core\Menu\LocalTaskManager::isRouteActive()
- 10 core/lib/Drupal/Core/Menu/LocalTaskManager.php \Drupal\Core\Menu\LocalTaskManager::isRouteActive()
- 11.x core/lib/Drupal/Core/Menu/LocalTaskManager.php \Drupal\Core\Menu\LocalTaskManager::isRouteActive()
Determines whether the route of a certain local task is currently active.
Parameters
string $current_route_name: The route name of the current main request.
string $route_name: The route name of the local task to determine the active status.
array $route_parameters: The parameter for the route.
Return value
bool Returns TRUE if the passed route_name and route_parameters is considered as the same as the one from the request, otherwise FALSE.
1 call to LocalTaskManager::isRouteActive()
- LocalTaskManager::getTasksBuild in core/
lib/ Drupal/ Core/ Menu/ LocalTaskManager.php - Gets the render array for all local tasks.
File
-
core/
lib/ Drupal/ Core/ Menu/ LocalTaskManager.php, line 398
Class
- LocalTaskManager
- Provides the default local task manager using YML as primary definition.
Namespace
Drupal\Core\MenuCode
protected function isRouteActive($current_route_name, $route_name, $route_parameters) {
// Flag the list element as active if this tab's route and parameters match
// the current request's route and route variables.
$active = $current_route_name == $route_name;
if ($active) {
// The request is injected, so we need to verify that we have the expected
// _raw_variables attribute.
$raw_variables_bag = $this->routeMatch
->getRawParameters();
// If we don't have _raw_variables, we assume the attributes are still the
// original values.
$raw_variables = $raw_variables_bag ? $raw_variables_bag->all() : $this->routeMatch
->getParameters()
->all();
$active = array_intersect_assoc($route_parameters, $raw_variables) == $route_parameters;
}
return $active;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.