1 | <?php |
||
20 | abstract class Base extends \Fiv\Form\Element\Html { |
||
21 | |||
22 | /** |
||
23 | * @var Form |
||
24 | */ |
||
25 | protected $form = null; |
||
26 | |||
27 | /** |
||
28 | * @var null|string |
||
29 | */ |
||
30 | protected $value = null; |
||
31 | |||
32 | /** |
||
33 | * @var \Fiv\Form\Validator\Base[] |
||
34 | */ |
||
35 | protected $validators = []; |
||
36 | |||
37 | /** |
||
38 | * @var null|boolean |
||
39 | */ |
||
40 | protected $validationResult = null; |
||
41 | |||
42 | /** |
||
43 | * @var \Fiv\Form\Filter\FilterInterface[] |
||
44 | */ |
||
45 | protected $filters = []; |
||
46 | |||
47 | /** |
||
48 | * @var string |
||
49 | */ |
||
50 | protected $text = ''; |
||
51 | |||
52 | |||
53 | /** |
||
54 | * Attach validator to current element |
||
55 | * |
||
56 | * @param \Fiv\Form\Validator\ValidatorInterface[]|\Fiv\Form\Validator\ValidatorInterface $validator |
||
57 | * @throws \Exception |
||
58 | * @return $this |
||
59 | */ |
||
60 | 5 | public function addValidator($validator) { |
|
74 | |||
75 | |||
76 | /** |
||
77 | * @param string $text |
||
78 | * @return $this |
||
79 | */ |
||
80 | 9 | public function setText($text) { |
|
84 | |||
85 | |||
86 | /** |
||
87 | * @return mixed |
||
88 | */ |
||
89 | public function getText() { |
||
92 | |||
93 | |||
94 | /** |
||
95 | * Attach filter to current element |
||
96 | * |
||
97 | * @param \Fiv\Form\Filter\FilterInterface|\Fiv\Form\Filter\FilterInterface[] $filter |
||
98 | * @throws \Exception |
||
99 | * @return $this |
||
100 | */ |
||
101 | 1 | public function addFilter($filter) { |
|
114 | |||
115 | |||
116 | /** |
||
117 | * @param $value |
||
118 | * @return $this |
||
119 | */ |
||
120 | 12 | public function setValue($value) { |
|
131 | |||
132 | |||
133 | /** |
||
134 | * @return \Fiv\Form\Filter\FilterInterface[] |
||
135 | */ |
||
136 | 12 | public function getFilters() { |
|
139 | |||
140 | |||
141 | /** |
||
142 | * Return true if element is valid |
||
143 | * @return boolean |
||
144 | */ |
||
145 | 6 | public function validate() { |
|
162 | |||
163 | |||
164 | /** |
||
165 | * @return string |
||
166 | */ |
||
167 | 8 | public function getValue() { |
|
170 | |||
171 | |||
172 | /** |
||
173 | * @return \Fiv\Form\Validator\Base[] |
||
174 | */ |
||
175 | 6 | public function getValidators() { |
|
178 | |||
179 | |||
180 | /** |
||
181 | * @return array |
||
182 | */ |
||
183 | public function getValidatorsErrors() { |
||
191 | |||
192 | |||
193 | /** |
||
194 | * @return $this |
||
195 | */ |
||
196 | public function required() { |
||
199 | |||
200 | |||
201 | } |