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