function moderation_dashboard_toolbar_alter in Moderation Dashboard 2.0.x
Same name and namespace in other branches
- 8 moderation_dashboard.module \moderation_dashboard_toolbar_alter()
Implements hook_toolbar_alter().
File
- ./
moderation_dashboard.module, line 62 - Contains hooks for the moderation_dashboard module.
Code
function moderation_dashboard_toolbar_alter(&$items) {
$user = \Drupal::currentUser();
if (isset($items['user']) && $user
->hasPermission('use moderation dashboard')) {
$items['user']['tray']['moderation_dashboard'] = [
'#theme' => 'links__toolbar_user',
'#links' => [
'moderation_dashboard_link' => [
'title' => t('Moderation Dashboard'),
'url' => Url::fromRoute('view.moderation_dashboard.page_1', [
'user' => $user
->id(),
]),
'attributes' => [
'title' => t('View the Moderation Dashboard page'),
],
],
],
'#attributes' => [
'class' => [
'toolbar-menu',
],
],
'#cache' => [
'contexts' => [
'user.permissions',
],
],
];
}
return $items;
}