function ContextualHooks::toolbar
Implements hook_toolbar().
File
-
core/
modules/ contextual/ src/ Hook/ ContextualHooks.php, line 18
Class
- ContextualHooks
- Hook implementations for contextual.
Namespace
Drupal\contextual\HookCode
public function 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.