function quickedit_page_attachments

Same name in other branches
  1. 9 core/modules/quickedit/quickedit.module \quickedit_page_attachments()

Implements hook_page_attachments().

Adds the quickedit library to the page for any user who has the 'access in-place editing' permission.

File

core/modules/quickedit/quickedit.module, line 46

Code

function quickedit_page_attachments(array &$page) {
    if (!\Drupal::currentUser()->hasPermission('access in-place editing')) {
        return;
    }
    // In-place editing is only supported on the front-end.
    if (\Drupal::service('router.admin_context')->isAdminRoute()) {
        return;
    }
    $page['#attached']['drupalSettings']['quickedit']['csrf_token'] = \Drupal::csrfToken()->get('X-Drupal-Quickedit-CSRF-Token');
    $page['#attached']['library'][] = 'quickedit/quickedit';
}

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