You are here

public function PageAttachments::alter in Express 8

Alters data for a specific hook_TYPE_alter() implementation.

Parameters

mixed $data: The variable that will be passed to hook_TYPE_alter() implementations to be altered. The type of this variable depends on the value of the $type argument. For example, when altering a 'form', $data will be a structured array. When altering a 'profile', $data will be an object.

mixed $context1: (optional) An additional variable that is passed by reference.

mixed $context2: (optional) An additional variable that is passed by reference. If more context needs to be provided to implementations, then this should be an associative array as described above.

Overrides AlterInterface::alter

File

themes/contrib/bootstrap/src/Plugin/Alter/PageAttachments.php, line 24
Contains \Drupal\bootstrap\Plugin\Alter\PageAttachments.

Class

PageAttachments
Implements hook_page_attachments_alter().

Namespace

Drupal\bootstrap\Plugin\Alter

Code

public function alter(&$attachments, &$context1 = NULL, &$context2 = NULL) {
  if ($this->theme
    ->livereloadUrl()) {
    $attachments['#attached']['library'][] = 'bootstrap/livereload';
  }
  if ($this->theme
    ->getSetting('popover_enabled')) {
    $attachments['#attached']['library'][] = 'bootstrap/popover';
  }
  if ($this->theme
    ->getSetting('tooltip_enabled')) {
    $attachments['#attached']['library'][] = 'bootstrap/tooltip';
  }
  $attachments['#attached']['drupalSettings']['bootstrap'] = $this->theme
    ->drupalSettings();
}