function contextual_toolbar
Same name in other branches
- 8.9.x core/modules/contextual/contextual.module \contextual_toolbar()
- 10 core/modules/contextual/contextual.module \contextual_toolbar()
Implements hook_toolbar().
File
-
core/
modules/ contextual/ contextual.module, line 17
Code
function contextual_toolbar() {
$items = [];
$items['contextual'] = [
'#cache' => [
'contexts' => [
'user.permissions',
],
],
];
if (!\Drupal::currentUser()->hasPermission('access contextual links')) {
return $items;
}
$items['contextual'] += [
'#type' => 'toolbar_item',
'tab' => [
'#type' => 'html_tag',
'#tag' => 'button',
'#value' => t('Edit'),
'#attributes' => [
'class' => [
'toolbar-icon',
'toolbar-icon-edit',
],
'aria-pressed' => 'false',
'type' => 'button',
],
],
'#wrapper_attributes' => [
'class' => [
'hidden',
'contextual-toolbar-tab',
],
],
'#attached' => [
'library' => [
'contextual/drupal.contextual-toolbar',
],
],
];
return $items;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.