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