protected function CoffeeController::getLocalTasksForRoute in Coffee 8
Retrieve all the local tasks for a given route.
Every element returned by this method is already access checked.
Parameters
string $route_name: The route name for which find the local tasks.
array $route_parameters: The route parameters.
Return value
array A flatten array that contains the local tasks for the given route. Each element in the array is keyed by the route name associated with the local tasks and contains:
- title: the title of the local task.
- url: the url object for the local task.
- localized_options: the localized options for the local task.
1 call to CoffeeController::getLocalTasksForRoute()
- CoffeeController::coffeeData in src/
Controller/ CoffeeController.php - Outputs the data that is used for the Coffee autocompletion in JSON.
File
- src/
Controller/ CoffeeController.php, line 200
Class
- CoffeeController
- Provides route responses for coffee.module.
Namespace
Drupal\coffee\ControllerCode
protected function getLocalTasksForRoute($route_name, array $route_parameters) {
$links = [];
$tree = $this->localTaskManager
->getLocalTasksForRoute($route_name);
foreach ($tree as $instances) {
/* @var $instances \Drupal\Core\Menu\LocalTaskInterface[] */
foreach ($instances as $child) {
$child_route_name = $child
->getRouteName();
// Merges the parent's route parameter with the child ones since you
// calculate the local tasks outside of parent route context.
$child_route_parameters = $child
->getRouteParameters($this->routeMatch) + $route_parameters;
if (strpos($child_route_name, 'config_translate') !== FALSE && $this->accessManager
->checkNamedRoute($child_route_name, $child_route_parameters)) {
$links[$child_route_name] = [
'title' => $child
->getTitle(),
'url' => Url::fromRoute($child_route_name, $child_route_parameters),
'localized_options' => $child
->getOptions($this->routeMatch),
];
}
}
}
return $links;
}