function workbench_toolbar in Workbench 8
Implements hook_toolbar().
File
- ./
workbench.module, line 37 - Workbench module file.
Code
function workbench_toolbar() {
// The 'Workbench' tab is a simple link, with no corresponding tray.
$user = \Drupal::currentUser();
$items = [];
if ($user
->hasPermission('access workbench')) {
$items['workbench'] = [
'#type' => 'toolbar_item',
'tab' => [
'#type' => 'link',
'#title' => t('Workbench'),
'#url' => Url::fromRoute('workbench.content'),
'#attributes' => [
'title' => t('My personal editorial workspace'),
'class' => [
'toolbar-icon',
'toolbar-icon-workbench-content-tab',
],
],
],
'tray' => [
'#heading' => t('Your Workbench'),
'workbench_toolbar' => [
'#pre_render' => [
[
WorkbenchToolbar::class,
'preRenderTray',
],
],
],
'#type' => 'container',
],
'#attached' => [
'library' => [
'workbench/workbench.toolbar',
],
],
'#weight' => -18,
];
}
return $items;
}