1 | <?php |
||
16 | abstract class PostListAbstract extends ComponentBase |
||
|
|||
17 | { |
||
18 | use UrlHelperTrait; |
||
19 | |||
20 | /** |
||
21 | * @var Collection | array |
||
22 | */ |
||
23 | public $posts = []; |
||
24 | |||
25 | /** |
||
26 | * @var integer The current page |
||
27 | */ |
||
28 | public $currentPage; |
||
29 | |||
30 | /** |
||
31 | * @var integer The number of results per page |
||
32 | */ |
||
33 | public $resultsPerPage; |
||
34 | |||
35 | /** |
||
36 | * Message to display when there are no posts |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | public $noPostsMessage; |
||
41 | |||
42 | /** |
||
43 | * If the post list should be ordered by another attribute |
||
44 | * |
||
45 | * @var string |
||
46 | */ |
||
47 | public $orderBy; |
||
48 | |||
49 | /** |
||
50 | * The attributes on which the post list can be ordered |
||
51 | * @var array |
||
52 | */ |
||
53 | public static $postAllowedSortingOptions = [ |
||
54 | 'title asc' => 'Title (ascending)', |
||
55 | 'title desc' => 'Title (descending)', |
||
56 | 'created_at asc' => 'Created (ascending)', |
||
57 | 'created_at desc' => 'Created (descending)', |
||
58 | 'updated_at asc' => 'Updated (ascending)', |
||
59 | 'updated_at desc' => 'Updated (descending)', |
||
60 | 'published_at asc' => 'Published (ascending)', |
||
61 | 'published_at desc' => 'Published (descending)', |
||
62 | 'random' => 'Random' |
||
63 | ]; |
||
64 | |||
65 | /** |
||
66 | * Component Properties |
||
67 | * @return array |
||
68 | */ |
||
69 | public function defineProperties() |
||
120 | |||
121 | /** |
||
122 | * @see Post::$allowedSortingOptions |
||
123 | * |
||
124 | * @return mixed |
||
125 | */ |
||
126 | public function getOrderByOptions() |
||
130 | |||
131 | /** |
||
132 | * Query the tag and posts belonging to it |
||
133 | */ |
||
134 | public function onRun() |
||
144 | |||
145 | /** |
||
146 | * Prepare variables |
||
147 | */ |
||
148 | abstract protected function prepareContextItem(); |
||
149 | |||
150 | /** |
||
151 | * Prepare variables |
||
152 | */ |
||
153 | protected function prepareVars() |
||
166 | |||
167 | /** |
||
168 | * Load a list of posts |
||
169 | */ |
||
170 | public function listPosts() |
||
193 | |||
194 | /** |
||
195 | * @return mixed |
||
196 | */ |
||
197 | abstract protected function getPostsQuery(); |
||
198 | |||
199 | /** |
||
200 | * @return mixed |
||
201 | */ |
||
202 | public function getPostPageOptions() |
||
206 | |||
207 | /** |
||
208 | * @return mixed |
||
209 | */ |
||
210 | public function getCategoryPageOptions() |
||
214 | } |
||
215 |
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.