function contextual_page_attachments

Same name in other branches
  1. 9 core/modules/contextual/contextual.module \contextual_page_attachments()
  2. 10 core/modules/contextual/contextual.module \contextual_page_attachments()
  3. 11.x core/modules/contextual/contextual.module \contextual_page_attachments()

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 64

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.