1 | <?php |
||
19 | abstract class AbstractListView |
||
20 | { |
||
21 | /** @var string Module name. */ |
||
22 | protected $moduleName; |
||
23 | |||
24 | /** @var string[] Column fields */ |
||
25 | protected $fields = []; |
||
26 | |||
27 | /** @var array Records list from api. */ |
||
28 | protected $recordsList = []; |
||
29 | |||
30 | /** @var int Current page. */ |
||
31 | private $page = 1; |
||
32 | |||
33 | /** @var int The number of items on the page. */ |
||
34 | protected $limit = 0; |
||
35 | |||
36 | /** @var int Offset. */ |
||
37 | protected $offset = 0; |
||
38 | |||
39 | /** @var string Sorting direction. */ |
||
40 | protected $order; |
||
41 | |||
42 | /** @var string Sets the ORDER BY part of the query record list. */ |
||
43 | protected $orderField; |
||
44 | |||
45 | /** @var array Conditions. */ |
||
46 | protected $conditions = []; |
||
47 | |||
48 | /** @var bool Use raw data. */ |
||
49 | protected $rawData = false; |
||
50 | |||
51 | protected $actionName = 'RecordsList'; |
||
52 | |||
53 | /** |
||
54 | * Get instance. |
||
55 | * |
||
56 | * @param string $moduleName |
||
57 | * @param string $viewName |
||
58 | * |
||
59 | * @return self |
||
|
|||
60 | */ |
||
61 | public static function getInstance(string $moduleName, string $viewName = 'ListView'): self |
||
69 | |||
70 | /** |
||
71 | * Function to get the Module Model. |
||
72 | * |
||
73 | * @return string |
||
74 | */ |
||
75 | public function getModuleName(): string |
||
79 | |||
80 | /** |
||
81 | * Function to set raw data. |
||
82 | * |
||
83 | * @param bool $rawData |
||
84 | * |
||
85 | * @return self |
||
86 | */ |
||
87 | public function setRawData(bool $rawData): self |
||
92 | |||
93 | /** |
||
94 | * Set custom fields. |
||
95 | * |
||
96 | * @param array $fields |
||
97 | * |
||
98 | * @return self |
||
99 | */ |
||
100 | public function setFields(array $fields): self |
||
105 | |||
106 | /** |
||
107 | * Set limit. |
||
108 | * |
||
109 | * @param int $limit |
||
110 | * |
||
111 | * @return self |
||
112 | */ |
||
113 | public function setLimit(int $limit): self |
||
118 | |||
119 | /** |
||
120 | * Set offset. |
||
121 | * |
||
122 | * @param int $offset |
||
123 | * |
||
124 | * @return self |
||
125 | */ |
||
126 | public function setOffset(int $offset): self |
||
131 | |||
132 | /** |
||
133 | * Set order. |
||
134 | * |
||
135 | * @param string $field |
||
136 | * @param string $direction |
||
137 | * |
||
138 | * @return self |
||
139 | */ |
||
140 | public function setOrder(string $field, string $direction): self |
||
146 | |||
147 | /** |
||
148 | * Set conditions. |
||
149 | * |
||
150 | * @param array $conditions |
||
151 | * |
||
152 | * @return void |
||
153 | */ |
||
154 | public function setConditions(array $conditions) |
||
158 | |||
159 | /** |
||
160 | * Load a list of records from the API. |
||
161 | * |
||
162 | * @return self |
||
163 | */ |
||
164 | public function loadRecordsList(): self |
||
187 | |||
188 | /** |
||
189 | * Get data from api. |
||
190 | * |
||
191 | * @param array $headers |
||
192 | * |
||
193 | * @return array |
||
194 | */ |
||
195 | protected function getFromApi(array $headers): array |
||
201 | |||
202 | /** |
||
203 | * Get records list model. |
||
204 | * |
||
205 | * @return Record[] |
||
206 | */ |
||
207 | public function getRecordsListModel(): array |
||
228 | |||
229 | /** |
||
230 | * Get headers of list. |
||
231 | * |
||
232 | * @return array |
||
233 | */ |
||
234 | public function getHeaders(): array |
||
243 | |||
244 | /** |
||
245 | * Get all rows count. |
||
246 | * |
||
247 | * @return int |
||
248 | */ |
||
249 | public function getCount(): int |
||
253 | |||
254 | /** |
||
255 | * Get current page. |
||
256 | * |
||
257 | * @return int |
||
258 | */ |
||
259 | public function getPage(): int |
||
266 | |||
267 | /** |
||
268 | * Sets page number. |
||
269 | * |
||
270 | * @param int $page |
||
271 | * |
||
272 | * @return $this |
||
273 | */ |
||
274 | public function setPage(int $page) |
||
279 | |||
280 | /** |
||
281 | * Is there more pages. |
||
282 | * |
||
283 | * @return bool |
||
284 | */ |
||
285 | public function isMorePages(): bool |
||
289 | } |
||
290 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.