You are here

function acquia_lift_page_attachments in Acquia Lift Connector 8.3

Same name and namespace in other branches
  1. 8.4 acquia_lift.module \acquia_lift_page_attachments()
  2. 8 acquia_lift.module \acquia_lift_page_attachments()

Implements hook_page_attachments().

File

./acquia_lift.module, line 25

Code

function acquia_lift_page_attachments(array &$page) {

  // Create and attach settings and library only when path context agrees on attaching.
  $path_context = \Drupal::service('acquia_lift.service.context.path_context');
  if (!$path_context
    ->shouldAttach()) {
    return;
  }
  $page_context = \Drupal::service('acquia_lift.service.context.page_context');

  // Populate contexts.
  $path_context
    ->populate($page);
  $page_context
    ->populate($page);

  // Attach Toolbar CSS Adjustment to all pages if the toolbar is present. This
  // is because we want the toolbar to shrink along with the lift experience
  // tools.
  if (\Drupal::currentUser()
    ->hasPermission('access toolbar')) {
    $page['#attached']['library'][] = 'acquia_lift/acquia-lift-toolbar';
  }
}