Version 1
[yaffs-website] / web / themes / contrib / bootstrap / src / Plugin / Preprocess / Links.php
1 <?php
2 /**
3  * @file
4  * Contains \Drupal\bootstrap\Plugin\Preprocess\Links.
5  */
6
7 namespace Drupal\bootstrap\Plugin\Preprocess;
8
9 use Drupal\bootstrap\Annotation\BootstrapPreprocess;
10 use Drupal\bootstrap\Utility\Element;
11 use Drupal\bootstrap\Utility\Variables;
12
13 /**
14  * Pre-processes variables for the "links" theme hook.
15  *
16  * @ingroup plugins_preprocess
17  *
18  * @BootstrapPreprocess("links")
19  */
20 class Links extends PreprocessBase implements PreprocessInterface {
21
22   /**
23    * {@inheritdoc}
24    */
25   public function preprocessVariables(Variables $variables) {
26     if ($variables->theme_hook_original === 'links' && $variables->hasClass('operations')) {
27       $variables->addClass('list-inline');
28       foreach ($variables->links as &$data) {
29         $link = Element::create($data['link']);
30         $link->addClass(['btn', 'btn-sm']);
31         $link->colorize();
32         $link->setIcon();
33         if ($this->theme->getSetting('tooltip_enabled')) {
34           $link->setAttribute('data-toggle', 'tooltip');
35           $link->setAttribute('data-placement', 'bottom');
36         }
37       }
38     }
39     $this->preprocessAttributes();
40   }
41
42 }