function contextual_toolbar in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/contextual/contextual.module \contextual_toolbar()
Implements hook_toolbar().
File
- core/
modules/ contextual/ contextual.module, line 16 - Adds contextual links to perform actions related to elements on a page.
Code
function contextual_toolbar() {
$items = [];
$items['contextual'] = [
'#cache' => [
'contexts' => [
'user.permissions',
],
],
];
if (!\Drupal::currentUser()
->hasPermission('access contextual links')) {
return $items;
}
$items['contextual'] += array(
'#type' => 'toolbar_item',
'tab' => array(
'#type' => 'html_tag',
'#tag' => 'button',
'#value' => t('Edit'),
'#attributes' => array(
'class' => array(
'toolbar-icon',
'toolbar-icon-edit',
),
'role' => 'button',
'aria-pressed' => 'false',
),
),
'#wrapper_attributes' => array(
'class' => array(
'hidden',
'contextual-toolbar-tab',
),
),
'#attached' => array(
'library' => array(
'contextual/drupal.contextual-toolbar',
),
),
);
return $items;
}