Updated the Bootstrap theme.
[yaffs-website] / web / themes / contrib / bootstrap / src / Plugin / Preprocess / ImageWidget.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 "image_widget" theme hook.
10  *
11  * @ingroup plugins_preprocess
12  *
13  * @see image-widget.html.twig
14  *
15  * @BootstrapPreprocess("image_widget",
16  *   replace = "template_preprocess_image_widget"
17  * )
18  */
19 class ImageWidget extends PreprocessBase implements PreprocessInterface {
20
21   /**
22    * {@inheritdoc}
23    */
24   public function preprocessElement(Element $element, Variables $variables) {
25     $variables->addClass([
26       'image-widget',
27       'js-form-managed-file',
28       'form-managed-file',
29       'clearfix',
30     ]);
31
32     $data = &$variables->offsetGet('data', []);
33     foreach ($element->children() as $key => $child) {
34       $data[$key] = $child->getArray();
35     }
36   }
37
38 }