Version 1
[yaffs-website] / web / themes / contrib / bootstrap / src / Plugin / Preprocess / InputButton.php
1 <?php
2 /**
3  * @file
4  * Contains \Drupal\bootstrap\Plugin\Preprocess\InputButton.
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 "input__button" theme hook.
15  *
16  * @ingroup plugins_preprocess
17  *
18  * @BootstrapPreprocess("input__button")
19  */
20 class InputButton extends Input implements PreprocessInterface {
21
22   /**
23    * {@inheritdoc}
24    */
25   public function preprocessElement(Element $element, Variables $variables) {
26     $element->colorize();
27     $element->setButtonSize();
28     $element->setIcon($element->getProperty('icon'));
29     $variables['icon_only'] = $element->getProperty('icon_only');
30     $variables['icon_position'] = $element->getProperty('icon_position');
31     $variables['label'] = $element->getProperty('value');
32     if ($element->getProperty('split')) {
33       $variables->map([$variables::SPLIT_BUTTON]);
34     }
35     parent::preprocessElement($element, $variables);
36   }
37
38 }