file PageAttachments.php

Namespace

Drupal\bootstrap\Plugin\Alter
  1. <?php
  2. namespace Drupal\bootstrap\Plugin\Alter;
  3. use Drupal\bootstrap\Plugin\PluginBase;
  4. /**
  5. * Implements hook_page_attachments_alter().
  6. *
  7. * @ingroup plugins_alter
  8. *
  9. * @BootstrapAlter("page_attachments")
  10. */
  11. class PageAttachments extends PluginBase implements AlterInterface {
  12. /**
  13. * {@inheritdoc}
  14. */
  15. public function alter(&$attachments, &$context1 = NULL, &$context2 = NULL) {
  16. if ($this->theme->livereloadUrl()) {
  17. $attachments['#attached']['library'][] = 'bootstrap/livereload';
  18. }
  19. if ($this->theme->getSetting('popover_enabled')) {
  20. $attachments['#attached']['library'][] = 'bootstrap/popover';
  21. }
  22. if ($this->theme->getSetting('tooltip_enabled')) {
  23. $attachments['#attached']['library'][] = 'bootstrap/tooltip';
  24. }
  25. $attachments['#attached']['drupalSettings']['bootstrap'] = $this->theme->drupalSettings();
  26. }
  27. }

Classes