Skip to content
Snippets Groups Projects

sort local tasks

Closed quietone requested to merge issue/drupal-2219393:2219393-menu-local-tasks into 11.x
All threads resolved!
2 files
+ 124
0
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -360,6 +360,17 @@ public function getLocalTasks($route_name, $level = 0) {
foreach ($local_tasks as $tab_level => $items) {
$data[$tab_level] = empty($data[$tab_level]) ? $items : array_merge($data[$tab_level], $items);
}
// Sort by weight and alphabetically if weights are the same.
foreach ($data as $key => $values) {
$weights = array_column($values, '#weight');
array_multisort(
$weights, SORT_ASC, SORT_NUMERIC,
array_keys($values), SORT_ASC, SORT_NATURAL,
$data[$key],
);
}
$this->taskData[$route_name]['tabs'] = $data;
// Allow modules to alter local tasks.
$this->moduleHandler->alter('menu_local_tasks', $this->taskData[$route_name], $route_name, $cacheability);
Loading