1 | <?php |
||
18 | abstract class AbstractListView |
||
19 | { |
||
20 | /** @var string Module name. */ |
||
21 | protected $moduleName; |
||
22 | |||
23 | /** @var string[] Column fields */ |
||
24 | protected $fields = []; |
||
25 | |||
26 | /** @var array Records list from api. */ |
||
27 | protected $recordsList = []; |
||
28 | |||
29 | /** @var int The number of items on the page. */ |
||
30 | protected $limit = 0; |
||
31 | |||
32 | /** @var int Offset. */ |
||
33 | protected $offset = 0; |
||
34 | |||
35 | /** @var string Sorting direction. */ |
||
36 | protected $order; |
||
37 | |||
38 | /** @var string Sets the ORDER BY part of the query record list. */ |
||
39 | protected $orderField; |
||
40 | |||
41 | /** @var array Conditions. */ |
||
42 | protected $conditions = []; |
||
43 | |||
44 | /** @var bool Use raw data. */ |
||
45 | protected $rawData = false; |
||
46 | |||
47 | protected $actionName = 'RecordsList'; |
||
48 | |||
49 | /** |
||
50 | * Get instance. |
||
51 | * |
||
52 | * @param string $moduleName |
||
53 | * @param string $viewName |
||
54 | * |
||
55 | * @return self |
||
|
|||
56 | */ |
||
57 | public static function getInstance(string $moduleName, string $viewName = 'ListView'): self |
||
65 | |||
66 | /** |
||
67 | * Function to get the Module Model. |
||
68 | * |
||
69 | * @return string |
||
70 | */ |
||
71 | public function getModuleName(): string |
||
75 | |||
76 | /** |
||
77 | * Function to set raw data. |
||
78 | * |
||
79 | * @param bool $rawData |
||
80 | * |
||
81 | * @return self |
||
82 | */ |
||
83 | public function setRawData(bool $rawData): self |
||
88 | |||
89 | /** |
||
90 | * Set custom fields. |
||
91 | * |
||
92 | * @param array $fields |
||
93 | * |
||
94 | * @return self |
||
95 | */ |
||
96 | public function setFields(array $fields): self |
||
101 | |||
102 | /** |
||
103 | * Set limit. |
||
104 | * |
||
105 | * @param int $limit |
||
106 | * |
||
107 | * @return self |
||
108 | */ |
||
109 | public function setLimit(int $limit): self |
||
114 | |||
115 | /** |
||
116 | * Set offset. |
||
117 | * |
||
118 | * @param int $offset |
||
119 | * |
||
120 | * @return self |
||
121 | */ |
||
122 | public function setOffset(int $offset): self |
||
127 | |||
128 | /** |
||
129 | * Set order. |
||
130 | * |
||
131 | * @param string $field |
||
132 | * @param string $direction |
||
133 | * |
||
134 | * @return self |
||
135 | */ |
||
136 | public function setOrder(string $field, string $direction): self |
||
142 | |||
143 | /** |
||
144 | * Set conditions. |
||
145 | * |
||
146 | * @param array $conditions |
||
147 | * |
||
148 | * @return void |
||
149 | */ |
||
150 | public function setConditions(array $conditions) |
||
154 | |||
155 | /** |
||
156 | * Load a list of records from the API. |
||
157 | * |
||
158 | * @return self |
||
159 | */ |
||
160 | public function loadRecordsList(): self |
||
183 | |||
184 | /** |
||
185 | * Get data from api. |
||
186 | * |
||
187 | * @param array $headers |
||
188 | * |
||
189 | * @return array |
||
190 | */ |
||
191 | protected function getFromApi(array $headers): array |
||
197 | |||
198 | /** |
||
199 | * Get records list model. |
||
200 | * |
||
201 | * @return Record[] |
||
202 | */ |
||
203 | public function getRecordsListModel(): array |
||
224 | |||
225 | /** |
||
226 | * Get headers of list. |
||
227 | * |
||
228 | * @return array |
||
229 | */ |
||
230 | public function getHeaders(): array |
||
239 | |||
240 | /** |
||
241 | * Get all rows count. |
||
242 | * |
||
243 | * @return int |
||
244 | */ |
||
245 | public function getCount(): int |
||
249 | } |
||
250 |
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.