1 | <?php |
||
11 | abstract class BaseElement extends Html implements ElementInterface { |
||
12 | |||
13 | /** |
||
14 | * @var ValidatorInterface[] |
||
15 | */ |
||
16 | protected $validators = []; |
||
17 | |||
18 | /** |
||
19 | * @var FilterInterface[] |
||
20 | */ |
||
21 | protected $filters = []; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $text = ''; |
||
27 | |||
28 | /** |
||
29 | * @var null|string |
||
30 | */ |
||
31 | protected $value = null; |
||
32 | |||
33 | |||
34 | /** |
||
35 | * Attach validator to current element |
||
36 | * |
||
37 | * @param ValidatorInterface $validator |
||
38 | * @return $this |
||
39 | */ |
||
40 | public function addValidator(ValidatorInterface $validator) { |
||
44 | |||
45 | |||
46 | /** |
||
47 | * @return ValidatorInterface[] |
||
48 | */ |
||
49 | public function getValidators() { |
||
52 | |||
53 | |||
54 | /** |
||
55 | * |
||
56 | * @param FilterInterface $filter |
||
57 | * @return $this |
||
58 | */ |
||
59 | public function addFilter(FilterInterface $filter) { |
||
63 | |||
64 | |||
65 | /** |
||
66 | * @return FilterInterface[] |
||
67 | */ |
||
68 | public function getFilters() { |
||
71 | |||
72 | |||
73 | /** |
||
74 | * Alias of setAttribute('value', $value) |
||
75 | * |
||
76 | * @param $value |
||
77 | * @return $this |
||
78 | */ |
||
79 | public function setValue($value) { |
||
83 | |||
84 | |||
85 | /** |
||
86 | * @return string |
||
87 | */ |
||
88 | public function getValue() { |
||
91 | |||
92 | |||
93 | /** |
||
94 | * @inheritdoc |
||
95 | */ |
||
96 | public function setAttribute($name, $value) { |
||
110 | |||
111 | |||
112 | /** |
||
113 | * Return true if element is valid |
||
114 | * @return boolean |
||
115 | */ |
||
116 | public function isValid() { |
||
126 | |||
127 | |||
128 | /** |
||
129 | * @return array |
||
130 | */ |
||
131 | public function getValidatorsErrors() { |
||
141 | |||
142 | |||
143 | /** |
||
144 | * @inheritdoc |
||
145 | */ |
||
146 | public function render() { |
||
151 | |||
152 | |||
153 | /** |
||
154 | * @param string $text |
||
155 | * @return $this |
||
156 | */ |
||
157 | public function setText($text) { |
||
161 | |||
162 | |||
163 | /** |
||
164 | * @return mixed |
||
165 | */ |
||
166 | public function getText() { |
||
169 | |||
170 | |||
171 | /** |
||
172 | * @param string $name |
||
173 | * @return $this |
||
174 | */ |
||
175 | public function setName($name) { |
||
179 | |||
180 | |||
181 | /** |
||
182 | * @return null|string |
||
183 | */ |
||
184 | public function getName() { |
||
187 | |||
188 | |||
189 | /** |
||
190 | * @param string $class |
||
191 | * @return $this |
||
192 | */ |
||
193 | public function setClass($class) { |
||
197 | |||
198 | |||
199 | /** |
||
200 | * @return null|string |
||
201 | */ |
||
202 | public function getClass() { |
||
205 | |||
206 | |||
207 | /** |
||
208 | * @param string $id |
||
209 | * @return $this |
||
210 | */ |
||
211 | public function setId($id) { |
||
215 | |||
216 | |||
217 | /** |
||
218 | * @return null|string |
||
219 | */ |
||
220 | public function getId() { |
||
223 | |||
224 | } |