function maestro_menu_local_tasks_alter in Maestro 3.x
Same name and namespace in other branches
- 8.2 maestro.module \maestro_menu_local_tasks_alter()
Implements hook_menu_local_tasks_alter().
File
- ./
maestro.module, line 287 - Provides glue logic, hook implementation and core set process variable functions.
Code
function maestro_menu_local_tasks_alter(&$data, $route_name) {
// If we're viewing/editing a node AND we have a maestro and queueid query parameter.
$queueID = intval(\Drupal::request()->query
->get('queueid', 0));
$isMaestro = intval(\Drupal::request()->query
->get('maestro', 0));
if (($route_name == 'entity.node.edit_form' || $route_name == 'entity.node.canonical') && ($isMaestro > 0 || $queueID > 0) && MaestroEngine::canUserExecuteTask($queueID, \Drupal::currentUser()
->id())) {
$oldurl = $data['tabs'][0]['entity.node.edit_form']['#link']['url'];
$oldRouteParms = $oldurl
->getRouteParameters();
$url = Url::fromRoute('entity.node.edit_form', [
'node' => $oldRouteParms['node'],
], [
'query' => [
'maestro' => 1,
'queueid' => $queueID,
],
]);
$data['tabs'][0]['entity.node.edit_form']['#link']['url'] = $url;
$oldurl = $data['tabs'][0]['entity.node.canonical']['#link']['url'];
$oldRouteParms = $oldurl
->getRouteParameters();
$url = Url::fromRoute('entity.node.canonical', [
'node' => $oldRouteParms['node'],
], [
'query' => [
'maestro' => 1,
'queueid' => $queueID,
],
]);
$data['tabs'][0]['entity.node.canonical']['#link']['url'] = $url;
}
}