function shortcut_toolbar
Same name in other branches
- 8.9.x core/modules/shortcut/shortcut.module \shortcut_toolbar()
- 10 core/modules/shortcut/shortcut.module \shortcut_toolbar()
Implements hook_toolbar().
File
-
core/
modules/ shortcut/ shortcut.module, line 324
Code
function shortcut_toolbar() {
$user = \Drupal::currentUser();
$items = [];
$items['shortcuts'] = [
'#cache' => [
'contexts' => [
'user.permissions',
],
],
];
if ($user->hasPermission('access shortcuts')) {
$shortcut_set = shortcut_current_displayed_set();
$items['shortcuts'] += [
'#type' => 'toolbar_item',
'tab' => [
'#type' => 'link',
'#title' => t('Shortcuts'),
'#url' => $shortcut_set->toUrl('collection'),
'#attributes' => [
'title' => t('Shortcuts'),
'class' => [
'toolbar-icon',
'toolbar-icon-shortcut',
],
],
],
'tray' => [
'#heading' => t('User-defined shortcuts'),
'children' => [
'#lazy_builder' => [
'shortcut.lazy_builders:lazyLinks',
[],
],
'#create_placeholder' => TRUE,
'#cache' => [
'keys' => [
'shortcut_set_toolbar_links',
],
'contexts' => [
'user',
],
],
],
],
'#weight' => -10,
'#attached' => [
'library' => [
'shortcut/drupal.shortcut',
],
],
];
}
return $items;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.