PluginProbe
User Access Manager / trunk
User Access Manager vtrunk
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
user-access-manager / src / Form / FormFactory.php

FormFactory.php in User Access Manager trunk, at src/Form/FormFactory.php

73 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace UserAccessManager\Form;
6
7 use Exception;
8 use UserAccessManager\Form\Element\Input;
9 use UserAccessManager\Form\Element\MultipleFormElementValue;
10 use UserAccessManager\Form\Element\Radio;
11 use UserAccessManager\Form\Element\Select;
12 use UserAccessManager\Form\Element\Textarea;
13 use UserAccessManager\Form\Element\ValueSetFormElementValue;
14
15 class FormFactory
16 {
17 public function createForm(): Form
18 {
19 return new Form();
20 }
21
22 public function createValueSetFormElementValue(mixed $value, string $label): ValueSetFormElementValue
23 {
24 return new ValueSetFormElementValue($value, $label);
25 }
26
27 public function createMultipleFormElementValue(mixed $value, string $label): MultipleFormElementValue
28 {
29 return new MultipleFormElementValue($value, $label);
30 }
31
32 public function createInput(
33 string $id,
34 mixed $value = null,
35 ?string $label = null,
36 ?string $description = null
37 ): Input {
38 return new Input($id, $value, $label, $description);
39 }
40
41 public function createTextarea(
42 string $id,
43 mixed $value = null,
44 ?string $label = null,
45 ?string $description = null
46 ): Textarea {
47 return new Textarea($id, $value, $label, $description);
48 }
49
50 public function createSelect(
51 string $id,
52 array $possibleValues,
53 mixed $value = null,
54 ?string $label = null,
55 ?string $description = null
56 ): Select {
57 return new Select($id, $possibleValues, $value, $label, $description);
58 }
59
60 /**
61 * @throws Exception
62 */
63 public function createRadio(
64 string $id,
65 array $possibleValues,
66 mixed $value = null,
67 ?string $label = null,
68 ?string $description = null
69 ): Radio {
70 return new Radio($id, $possibleValues, $value, $label, $description);
71 }
72 }
73