8.5.x contextual.module contextual_page_attachments(array &$page)
8.0.x contextual.module contextual_page_attachments(array &$page)
8.1.x contextual.module contextual_page_attachments(array &$page)
8.2.x contextual.module contextual_page_attachments(array &$page)
8.3.x contextual.module contextual_page_attachments(array &$page)
8.4.x contextual.module contextual_page_attachments(array &$page)
8.6.x contextual.module contextual_page_attachments(array &$page)

Implements hook_page_attachments().

Adds the drupal.contextual-links library to the page for any user who has the 'access contextual links' permission.

See also

contextual_preprocess()

File

core/modules/contextual/contextual.module, line 62
Adds contextual links to perform actions related to elements on a page.

Code

function contextual_page_attachments(array &$page) {
  if (!\Drupal::currentUser()
    ->hasPermission('access contextual links')) {
    return;
  }
  $page['#attached']['library'][] = 'contextual/drupal.contextual-links';
}