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