Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
IslandConfigurationFormTrait
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 2
20
0.00% covered (danger)
0.00%
0 / 1
 validateConfigurationForm
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 submitConfigurationForm
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3declare(strict_types=1);
4
5namespace Drupal\display_builder;
6
7use Drupal\Component\Plugin\ConfigurableInterface;
8use Drupal\Core\Form\FormStateInterface;
9
10/**
11 * Add methods to make plugin configuration forms.
12 */
13trait IslandConfigurationFormTrait {
14
15  /**
16   * Validate the Island configuration.
17   *
18   * @param array $form
19   *   The form.
20   * @param \Drupal\Core\Form\FormStateInterface $form_state
21   *   The form state.
22   */
23  public function validateConfigurationForm(array &$form, FormStateInterface $form_state): void {}
24
25  /**
26   * Submit the island configuration.
27   *
28   * @param array $form
29   *   The form.
30   * @param \Drupal\Core\Form\FormStateInterface $form_state
31   *   The form state.
32   */
33  public function submitConfigurationForm(array &$form, FormStateInterface $form_state): void {
34    $values = $form_state->getValues();
35    $configuration = [];
36
37    foreach ($values as $key => $value) {
38      $configuration[$key] = $value;
39    }
40
41    if ($this instanceof ConfigurableInterface) {
42      $this->setConfiguration($configuration);
43    }
44  }
45
46}