1 | <?php |
||
14 | abstract class BaseElement extends Html implements ElementInterface { |
||
15 | |||
16 | /** |
||
17 | * @var ValidatorInterface[] |
||
18 | */ |
||
19 | protected $validators = []; |
||
20 | |||
21 | /** |
||
22 | * @var FilterInterface[] |
||
23 | */ |
||
24 | protected $filters = []; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $text = ''; |
||
30 | |||
31 | /** |
||
32 | * @var null|string |
||
33 | */ |
||
34 | protected $value = null; |
||
35 | |||
36 | |||
37 | /** |
||
38 | * @inheritdoc |
||
39 | */ |
||
40 | public abstract function handle(FormData $data); |
||
41 | |||
42 | |||
43 | /** |
||
44 | * Attach validator to current element |
||
45 | * |
||
46 | * @param ValidatorInterface $validator |
||
47 | * @return $this |
||
48 | */ |
||
49 | 7 | public function addValidator(ValidatorInterface $validator) { |
|
53 | |||
54 | |||
55 | /** |
||
56 | * @return ValidatorInterface[] |
||
57 | */ |
||
58 | 11 | public function getValidators() { |
|
61 | |||
62 | |||
63 | /** |
||
64 | * |
||
65 | * @param FilterInterface $filter |
||
66 | * @throws \Exception |
||
67 | * @return $this |
||
68 | */ |
||
69 | 4 | public function addFilter(FilterInterface $filter) { |
|
73 | |||
74 | |||
75 | /** |
||
76 | * @return FilterInterface[] |
||
77 | */ |
||
78 | 36 | public function getFilters() { |
|
81 | |||
82 | |||
83 | /** |
||
84 | * Alias of setAttribute('value', $value) |
||
85 | * |
||
86 | * @param $value |
||
87 | * @return $this |
||
88 | */ |
||
89 | 6 | public function setValue($value) { |
|
93 | |||
94 | |||
95 | /** |
||
96 | * @return string |
||
97 | */ |
||
98 | 40 | public function getValue() { |
|
101 | |||
102 | |||
103 | /** |
||
104 | * @inheritdoc |
||
105 | */ |
||
106 | 44 | public function setAttribute($name, $value) { |
|
120 | |||
121 | |||
122 | /** |
||
123 | * Return true if element is valid |
||
124 | * @return boolean |
||
125 | */ |
||
126 | 11 | public function isValid() { |
|
136 | |||
137 | |||
138 | /** |
||
139 | * @return array |
||
140 | */ |
||
141 | 6 | public function getValidatorsErrors() { |
|
151 | |||
152 | |||
153 | /** |
||
154 | * @inheritdoc |
||
155 | */ |
||
156 | 7 | public function render() { |
|
161 | |||
162 | |||
163 | /** |
||
164 | * @param string $text |
||
165 | * @return $this |
||
166 | */ |
||
167 | 17 | public function setText($text) { |
|
171 | |||
172 | |||
173 | /** |
||
174 | * @return mixed |
||
175 | */ |
||
176 | 1 | public function getText() { |
|
179 | |||
180 | |||
181 | /** |
||
182 | * @param string $name |
||
183 | * @return $this |
||
184 | */ |
||
185 | 42 | public function setName($name) { |
|
189 | |||
190 | |||
191 | /** |
||
192 | * @return null|string |
||
193 | */ |
||
194 | 38 | public function getName() { |
|
197 | |||
198 | |||
199 | /** |
||
200 | * @param string $class |
||
201 | * @return $this |
||
202 | */ |
||
203 | 1 | public function setClass($class) { |
|
207 | |||
208 | |||
209 | /** |
||
210 | * @return null|string |
||
211 | */ |
||
212 | 1 | public function getClass() { |
|
215 | |||
216 | |||
217 | /** |
||
218 | * @param string $id |
||
219 | * @return $this |
||
220 | */ |
||
221 | public function setId($id) { |
||
225 | |||
226 | |||
227 | /** |
||
228 | * @return null|string |
||
229 | */ |
||
230 | public function getId() { |
||
233 | |||
234 | } |