e30c1c2430b6ca5d46932ff910bc475a8aa1b8da
[yaffs-website] / web / themes / contrib / bootstrap / src / Plugin / Preprocess / Input.php
1 <?php
2 /**
3  * @file
4  * Contains \Drupal\bootstrap\Plugin\Preprocess\Input.
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" theme hook.
15  *
16  * @ingroup plugins_preprocess
17  *
18  * @BootstrapPreprocess("input")
19  */
20 class Input extends PreprocessBase implements PreprocessInterface {
21
22   /**
23    * {@inheritdoc}
24    */
25   public function preprocessElement(Element $element, Variables $variables) {
26     // Autocomplete.
27     if ($route = $element->getProperty('autocomplete_route_name')) {
28       $variables['autocomplete'] = TRUE;
29     }
30
31     // Create variables for #input_group and #input_group_button flags.
32     $variables['input_group'] = $element->getProperty('input_group') || $element->getProperty('input_group_button');
33
34     // Map the element properties.
35     $variables->map([
36       'attributes' => 'attributes',
37       'icon' => 'icon',
38       'field_prefix' => 'prefix',
39       'field_suffix' => 'suffix',
40       'type' => 'type',
41     ]);
42
43     // Ensure attributes are proper objects.
44     $this->preprocessAttributes();
45   }
46
47 }