function maestro_toolbar in Maestro 8.2
Same name and namespace in other branches
- 3.x maestro.module \maestro_toolbar()
Implements hook_toolbar() for adding the Maestro toolbar.
File
- ./
maestro.module, line 441 - Provides glue logic, hook implementation and core set process variable functions.
Code
function maestro_toolbar() {
$items = [];
$items['Maestro'] = [
'#cache' => [
'contexts' => [
'user.permissions',
],
],
];
// Need at least this permission to view the maestro toolbar.
if (!\Drupal::currentUser()
->hasPermission('view maestro task console')) {
return $items;
}
$items['Maestro'] += [
'#type' => 'toolbar_item',
'#weight' => 1,
'tab' => [
'#type' => 'link',
'#title' => 'Maestro',
'#url' => Url::fromRoute("<front>"),
'#attributes' => [
'title' => 'Maestro menu',
'class' => [
'toolbar-icon',
'toolbar-icon-devel',
],
],
],
'tray' => [
'configuration' => [],
'#attached' => [
'library' => [
'maestro/maestro-toolbar',
],
],
],
];
if (\Drupal::moduleHandler()
->moduleExists('maestro_taskconsole')) {
$items['Maestro']['tray']['configuration'][] = [
'#type' => 'link',
'#title' => 'Task Console',
'#url' => Url::fromUri("internal:/taskconsole"),
];
}
// Add more toolbar menu items depending on access.
if (\Drupal::currentUser()
->hasPermission('administer maestro templates')) {
if (\Drupal::moduleHandler()
->moduleExists('maestro_template_builder')) {
$items['Maestro']['tray']['configuration'][] = [
'#type' => 'link',
'#title' => 'Template Builder',
'#url' => Url::fromUri("internal:/maestro/templates/list"),
];
}
}
if (\Drupal::currentUser()
->hasPermission('administer maestro queue entities')) {
$config = \Drupal::config('maestro.settings');
$token = $config
->get('maestro_orchestrator_token');
$items['Maestro']['tray']['configuration'][] = [
'#type' => 'link',
'#title' => 'Run Orchestrator',
'#url' => Url::fromRoute("maestro.orchestrator", [
'token' => $token,
]),
];
$items['Maestro']['tray']['configuration'][] = [
'#type' => 'link',
'#title' => 'Outstanding Tasks',
'#url' => Url::fromUri("internal:/outstanding-tasks"),
];
$items['Maestro']['tray']['configuration'][] = [
'#type' => 'link',
'#title' => 'All Active Tasks',
'#url' => Url::fromUri("internal:/maestro-all-in-production-tasks"),
];
$items['Maestro']['tray']['configuration'][] = [
'#type' => 'link',
'#title' => 'Workflow History',
'#url' => Url::fromUri("internal:/maestro-all-flows"),
];
}
return $items;
}