1 | <?php |
||
15 | abstract class BaseElement extends Html implements ElementInterface { |
||
16 | |||
17 | /** |
||
18 | * @var \Fiv\Form\Validator\Base[] |
||
19 | */ |
||
20 | protected $validators = []; |
||
21 | |||
22 | /** |
||
23 | * @var FilterInterface[] |
||
24 | */ |
||
25 | protected $filters = []; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $text = ''; |
||
31 | |||
32 | /** |
||
33 | * @var null|string |
||
34 | */ |
||
35 | protected $value = null; |
||
36 | |||
37 | |||
38 | /** |
||
39 | * @inheritdoc |
||
40 | */ |
||
41 | public abstract function handle(FormData $data); |
||
42 | |||
43 | |||
44 | /** |
||
45 | * Attach validator to current element |
||
46 | * |
||
47 | * @param ValidatorInterface $validator |
||
48 | * @return $this |
||
49 | */ |
||
50 | 7 | public function addValidator(ValidatorInterface $validator) { |
|
54 | |||
55 | |||
56 | /** |
||
57 | * @return \Fiv\Form\Validator\Base[] |
||
58 | */ |
||
59 | 11 | public function getValidators() { |
|
62 | |||
63 | |||
64 | /** |
||
65 | * |
||
66 | * @param FilterInterface $filter |
||
67 | * @throws \Exception |
||
68 | * @return $this |
||
69 | */ |
||
70 | 4 | public function addFilter(FilterInterface $filter) { |
|
74 | |||
75 | |||
76 | /** |
||
77 | * @return FilterInterface[] |
||
78 | */ |
||
79 | 32 | public function getFilters() { |
|
82 | |||
83 | |||
84 | /** |
||
85 | * Alias of setAttribute('value', $value) |
||
86 | * |
||
87 | * @param $value |
||
88 | * @return $this |
||
89 | */ |
||
90 | 6 | public function setValue($value) { |
|
94 | |||
95 | |||
96 | /** |
||
97 | * @return string |
||
98 | */ |
||
99 | 35 | public function getValue() { |
|
102 | |||
103 | |||
104 | /** |
||
105 | * @inheritdoc |
||
106 | */ |
||
107 | 40 | public function setAttribute($name, $value) { |
|
121 | |||
122 | |||
123 | /** |
||
124 | * Return true if element is valid |
||
125 | * @return boolean |
||
126 | */ |
||
127 | 11 | public function isValid() { |
|
138 | |||
139 | |||
140 | /** |
||
141 | * @return bool |
||
142 | */ |
||
143 | public function validate() { |
||
147 | |||
148 | |||
149 | /** |
||
150 | * @return array |
||
151 | */ |
||
152 | 6 | public function getValidatorsErrors() { |
|
162 | |||
163 | |||
164 | /** |
||
165 | * @inheritdoc |
||
166 | */ |
||
167 | 7 | public function render() { |
|
172 | |||
173 | |||
174 | /** |
||
175 | * @deprecated |
||
176 | * @see addValidator |
||
177 | * @return $this |
||
178 | */ |
||
179 | public function required() { |
||
183 | |||
184 | |||
185 | /** |
||
186 | * @param string $text |
||
187 | * @return $this |
||
188 | */ |
||
189 | 17 | public function setText($text) { |
|
193 | |||
194 | |||
195 | /** |
||
196 | * @return mixed |
||
197 | */ |
||
198 | 1 | public function getText() { |
|
201 | |||
202 | |||
203 | /** |
||
204 | * @param string $name |
||
205 | * @return $this |
||
206 | */ |
||
207 | 38 | public function setName($name) { |
|
211 | |||
212 | |||
213 | /** |
||
214 | * @return null|string |
||
215 | */ |
||
216 | 34 | public function getName() { |
|
219 | |||
220 | |||
221 | /** |
||
222 | * @param string $class |
||
223 | * @return $this |
||
224 | */ |
||
225 | 1 | public function setClass($class) { |
|
229 | |||
230 | |||
231 | /** |
||
232 | * @return null|string |
||
233 | */ |
||
234 | 1 | public function getClass() { |
|
237 | |||
238 | |||
239 | /** |
||
240 | * @param string $id |
||
241 | * @return $this |
||
242 | */ |
||
243 | public function setId($id) { |
||
247 | |||
248 | |||
249 | /** |
||
250 | * @return null|string |
||
251 | */ |
||
252 | public function getId() { |
||
255 | |||
256 | } |