Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 7 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
IslandWithFormTrait | |
0.00% |
0 / 7 |
|
0.00% |
0 / 7 |
56 | |
0.00% |
0 / 1 |
getFormClass | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
hasFormClass | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
buildForm | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
validateForm | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
submitForm | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setBuilderId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setInstanceId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Drupal\display_builder; |
6 | |
7 | use Drupal\Core\Form\FormStateInterface; |
8 | use Drupal\display_builder\Form\IslandFormBase; |
9 | |
10 | /** |
11 | * Add methods to make plugin forms available. |
12 | */ |
13 | trait IslandWithFormTrait { |
14 | |
15 | /** |
16 | * Get the form class. |
17 | * |
18 | * @return string |
19 | * The form class. |
20 | */ |
21 | public static function getFormClass(): string { |
22 | return IslandFormBase::class; |
23 | } |
24 | |
25 | /** |
26 | * Check form class is defined. |
27 | * |
28 | * @return bool |
29 | * TRUE if form class is defined, FALSE otherwise. |
30 | */ |
31 | public static function hasFormClass(): bool { |
32 | return !empty(self::getFormClass()); |
33 | } |
34 | |
35 | /** |
36 | * Form constructor. |
37 | * |
38 | * @param array $form |
39 | * An associative array containing the structure of the form. |
40 | * @param \Drupal\Core\Form\FormStateInterface $form_state |
41 | * The current state of the form. |
42 | */ |
43 | public function buildForm(array &$form, FormStateInterface $form_state): void {} |
44 | |
45 | /** |
46 | * Form validation handler. |
47 | * |
48 | * @param array $form |
49 | * An associative array containing the structure of the form. |
50 | * @param \Drupal\Core\Form\FormStateInterface $form_state |
51 | * The current state of the form. |
52 | */ |
53 | public function validateForm(array &$form, FormStateInterface $form_state): void {} |
54 | |
55 | /** |
56 | * Form submission handler. |
57 | * |
58 | * @param array $form |
59 | * An associative array containing the structure of the form. |
60 | * @param \Drupal\Core\Form\FormStateInterface $form_state |
61 | * The current state of the form. |
62 | */ |
63 | public function submitForm(array &$form, FormStateInterface $form_state): void {} |
64 | |
65 | /** |
66 | * Set the builder id. |
67 | * |
68 | * @param string $builder_id |
69 | * The builder id. |
70 | * |
71 | * @todo remove this, should be on base class |
72 | */ |
73 | public function setBuilderId(string $builder_id): void { |
74 | $this->builderId = $builder_id; |
75 | } |
76 | |
77 | /** |
78 | * Get the builder id. |
79 | * |
80 | * @param string|null $instance_id |
81 | * The instance id. |
82 | * |
83 | * @todo remove this, should be on base class |
84 | */ |
85 | public function setInstanceId(?string $instance_id): void { |
86 | $this->instanceId = $instance_id; |
87 | } |
88 | |
89 | } |