1 | <?php declare(strict_types=1); |
||
19 | abstract class PostListAbstract extends ComponentAbstract |
||
|
|||
20 | { |
||
21 | use TranslateArrayTrait; |
||
22 | use PostListFiltersTrait; |
||
23 | |||
24 | /** |
||
25 | * @var Collection | array |
||
26 | */ |
||
27 | public $posts = []; |
||
28 | |||
29 | /** |
||
30 | * Parameter to use for the page number |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | public $pageParam; |
||
35 | |||
36 | /** |
||
37 | * @var integer The current page |
||
38 | */ |
||
39 | public $currentPage; |
||
40 | |||
41 | /** |
||
42 | * @var integer The number of results per page |
||
43 | */ |
||
44 | public $resultsPerPage; |
||
45 | |||
46 | /** |
||
47 | * If the post list should be ordered by another attribute |
||
48 | * |
||
49 | * @var string |
||
50 | */ |
||
51 | public $orderBy; |
||
52 | |||
53 | /** |
||
54 | * The attributes on which the post list can be ordered |
||
55 | * @var array |
||
56 | */ |
||
57 | public static $postAllowedSortingOptions = [ |
||
58 | 'title asc' => Plugin::LOCALIZATION_KEY . 'order_options.title_asc', |
||
59 | 'title desc' => Plugin::LOCALIZATION_KEY . 'order_options.title_desc', |
||
60 | 'created_at asc' => Plugin::LOCALIZATION_KEY . 'order_options.created_at_asc', |
||
61 | 'created_at desc' => Plugin::LOCALIZATION_KEY . 'order_options.created_at_desc', |
||
62 | 'updated_at asc' => Plugin::LOCALIZATION_KEY . 'order_options.updated_at_asc', |
||
63 | 'updated_at desc' => Plugin::LOCALIZATION_KEY . 'order_options.updated_at_desc', |
||
64 | 'published_at asc' => Plugin::LOCALIZATION_KEY . 'order_options.published_at_asc', |
||
65 | 'published_at desc' => Plugin::LOCALIZATION_KEY . 'order_options.published_at_desc', |
||
66 | 'random' => Plugin::LOCALIZATION_KEY . 'order_options.random' |
||
67 | ]; |
||
68 | |||
69 | /** |
||
70 | * Component properties |
||
71 | * |
||
72 | * @return array |
||
73 | */ |
||
74 | public function defineProperties(): array |
||
93 | |||
94 | /** |
||
95 | * @see Post::$allowedSortingOptions |
||
96 | * |
||
97 | * @return string[] |
||
98 | */ |
||
99 | public function getOrderByOptions(): array |
||
107 | |||
108 | /** |
||
109 | * Query the item and posts belonging to it |
||
110 | * |
||
111 | * @return void|RedirectResponse |
||
112 | */ |
||
113 | public function onRun() |
||
123 | |||
124 | /** |
||
125 | * Load a list of posts |
||
126 | */ |
||
127 | public function listPosts() |
||
141 | |||
142 | /** |
||
143 | * @return mixed |
||
144 | */ |
||
145 | public function getPostPageOptions() |
||
149 | |||
150 | /** |
||
151 | * @return mixed |
||
152 | */ |
||
153 | public function getCategoryPageOptions() |
||
157 | |||
158 | /** |
||
159 | * Prepare main context item |
||
160 | */ |
||
161 | abstract protected function prepareContextItem(); |
||
162 | |||
163 | /** |
||
164 | * @return mixed |
||
165 | */ |
||
166 | abstract protected function getPostsQuery(); |
||
167 | |||
168 | /** |
||
169 | * Prepare variables |
||
170 | */ |
||
171 | protected function prepareVars() |
||
182 | |||
183 | /** |
||
184 | * Properties for pagination handling |
||
185 | * |
||
186 | * @return array |
||
187 | */ |
||
188 | private function getPaginationProperties(): array |
||
210 | |||
211 | /** |
||
212 | * Properties for proper links handling |
||
213 | * |
||
214 | * @return array |
||
215 | */ |
||
216 | private function getPageLinkProperties(): array |
||
237 | |||
238 | /** |
||
239 | * @return void |
||
240 | */ |
||
241 | private function populatePagination() |
||
248 | |||
249 | /** |
||
250 | * @return void |
||
251 | */ |
||
252 | private function populateLinks() |
||
257 | |||
258 | /** |
||
259 | * @param $query |
||
260 | */ |
||
261 | private function handleOrder(Builder $query) |
||
273 | } |
||
274 |
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.