|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Lagdo\UiBuilder\Builder; |
|
4
|
|
|
|
|
5
|
|
|
use Lagdo\UiBuilder\Component\CheckboxComponent; |
|
6
|
|
|
use Lagdo\UiBuilder\Component\FormComponent; |
|
7
|
|
|
use Lagdo\UiBuilder\Component\InputGroupComponent; |
|
8
|
|
|
use Lagdo\UiBuilder\Component\LabelComponent; |
|
9
|
|
|
use Lagdo\UiBuilder\Component\OptionComponent; |
|
10
|
|
|
use Lagdo\UiBuilder\Component\RadioComponent; |
|
11
|
|
|
use Lagdo\UiBuilder\Component\Base\HtmlComponent; |
|
12
|
|
|
|
|
13
|
|
|
trait FormBuilderTrait |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* @return string |
|
17
|
|
|
*/ |
|
18
|
|
|
abstract protected function _formComponentClass(): string; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @return string |
|
22
|
|
|
*/ |
|
23
|
|
|
abstract protected function _labelComponentClass(): string; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @return string |
|
27
|
|
|
*/ |
|
28
|
|
|
abstract protected function _inputGroupComponentClass(): string; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @return string |
|
32
|
|
|
*/ |
|
33
|
|
|
abstract protected function _checkboxComponentClass(): string; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @return string |
|
37
|
|
|
*/ |
|
38
|
|
|
abstract protected function _radioComponentClass(): string; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @return string |
|
42
|
|
|
*/ |
|
43
|
|
|
abstract protected function _optionComponentClass(): string; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @param string $tagName |
|
47
|
|
|
* @param array $arguments |
|
48
|
|
|
* |
|
49
|
|
|
* @return HtmlComponent |
|
50
|
|
|
*/ |
|
51
|
|
|
abstract protected function createFormComponent(string $tagName, $arguments): HtmlComponent; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @inheritDoc |
|
55
|
|
|
*/ |
|
56
|
|
|
public function form(...$arguments): FormComponent |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->createComponentOfClass($this->_formComponentClass(), $arguments); |
|
|
|
|
|
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @inheritDoc |
|
63
|
|
|
*/ |
|
64
|
|
|
public function label(...$arguments): LabelComponent |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->createComponentOfClass($this->_labelComponentClass(), $arguments); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @inheritDoc |
|
71
|
|
|
*/ |
|
72
|
|
|
public function inputGroup(...$arguments): InputGroupComponent |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->createComponentOfClass($this->_inputGroupComponentClass(), $arguments); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @inheritDoc |
|
79
|
|
|
*/ |
|
80
|
|
|
public function checkbox(...$arguments): CheckboxComponent |
|
81
|
|
|
{ |
|
82
|
|
|
return $this->createComponentOfClass($this->_checkboxComponentClass(), $arguments); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @inheritDoc |
|
87
|
|
|
*/ |
|
88
|
|
|
public function radio(...$arguments): RadioComponent |
|
89
|
|
|
{ |
|
90
|
|
|
return $this->createComponentOfClass($this->_radioComponentClass(), $arguments); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @inheritDoc |
|
95
|
|
|
*/ |
|
96
|
|
|
public function option(...$arguments): OptionComponent |
|
97
|
|
|
{ |
|
98
|
|
|
return $this->createComponentOfClass($this->_optionComponentClass(), $arguments); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|