class PageAttachments

Implements hook_page_attachments_alter().

Plugin annotation

@BootstrapAlter("page_attachments")

Hierarchy

Expanded class hierarchy of PageAttachments

Related topics

Namespace

Drupal\bootstrap\Plugin\Alter
Source
class PageAttachments extends PluginBase implements AlterInterface {

  /**
   * {@inheritdoc}
   */
  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();
  }

}

Members

Contains filters are case sensitive
Name Modifiers Type Description
PageAttachments::alter public function Alters data for a specific hook_TYPE_alter() implementation. Overrides AlterInterface::alter
PluginBase::$theme protected property The currently set theme object.
PluginBase::__construct public function