function content_planner_toolbar in Content Planner 8
Implements hook_toolbar().
File
- ./
content_planner.module, line 45 - Contains content_planner.module.
Code
function content_planner_toolbar() {
$items = [];
$links['dashboard'] = [
'#type' => 'link',
'#title' => t('Dashboard'),
'#url' => Url::fromRoute('content_planner.dashboard'),
'#attributes' => [
'class' => 'toolbar-icon toolbar-icon-system-admin-reports',
],
];
$items['content_planner'] = [
'#type' => 'toolbar_item',
'tab' => [
'#type' => 'link',
'#title' => t('Content Planner'),
'#url' => Url::fromRoute('content_planner.dashboard'),
'#options' => [
'attributes' => [
'title' => t('Content Planner'),
'class' => [
'trigger',
'toolbar-item',
'toolbar-icon',
'toolbar-icon-system-admin-content',
],
],
],
],
'tray' => [
'#heading' => t('Content Planner sections'),
'links' => [
'#attributes' => [
'class' => [
'toolbar-menu',
],
],
'#theme' => 'item_list',
'#items' => $links,
],
],
'#weight' => -10,
'#cache' => [
'contexts' => [
'user.permissions',
],
],
];
if (\Drupal::currentUser()
->hasPermission('view content planner dashboard') || \Drupal::currentUser()
->hasPermission('administer content planner dashboard settings')) {
return $items;
}
}