Including security review as a submodule - with patched for Yaffs.
[yaffs-website] / web / modules / contrib / entity_browser / src / PluginConfigurationFormTrait.php
1 <?php
2
3 namespace Drupal\entity_browser;
4 use Drupal\Core\Form\FormStateInterface;
5
6 /**
7  * Provides base form methods for configurable plugins entity browser.
8  */
9 trait PluginConfigurationFormTrait {
10
11   /**
12    * Implements PluginFormInterface::buildConfigurationForm().
13    */
14   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
15     return $form;
16   }
17
18   /**
19    * Implements PluginFormInterface::validateConfigurationForm().
20    */
21   public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
22   }
23
24   /**
25    * Implements PluginFormInterface::submitConfigurationForm().
26    *
27    * This is the default implementation for the most common cases where the form
28    * element names match keys in configuration array. Plugins can override this
29    * if they need more complex logic.
30    */
31   public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
32     $values = $form_state->getValues();
33
34     if ($this instanceof WidgetInterface) {
35       $values = $values['table'][$this->uuid()]['form'];
36     }
37
38     if (!empty($values)) {
39       foreach ($values as $key => $value) {
40         if (array_key_exists($key, $this->configuration)) {
41           $this->configuration[$key] = $value;
42         }
43       }
44     }
45   }
46
47 }