1 | <?php |
||
28 | trait EntityListingMethods |
||
29 | { |
||
30 | |||
31 | /** |
||
32 | * @var int |
||
33 | */ |
||
34 | protected $rowsPerPage = 12; |
||
35 | |||
36 | /** |
||
37 | * @var Pagination |
||
38 | */ |
||
39 | protected $pagination; |
||
40 | |||
41 | /** |
||
42 | * @var EntityListingService |
||
43 | */ |
||
44 | protected $listingService; |
||
45 | |||
46 | /** |
||
47 | * @var string[] |
||
48 | */ |
||
49 | protected $searchFields; |
||
50 | |||
51 | /** |
||
52 | * Handle the request to display a list of entities |
||
53 | */ |
||
54 | 2 | public function index() |
|
67 | |||
68 | /** |
||
69 | * Get pagination for roes per page property |
||
70 | * |
||
71 | * @return Pagination |
||
72 | */ |
||
73 | 4 | protected function getPagination() |
|
85 | |||
86 | /** |
||
87 | * Get the entity listing service |
||
88 | * |
||
89 | * @return EntityListingService |
||
90 | */ |
||
91 | 4 | protected function getListingService() |
|
100 | |||
101 | /** |
||
102 | * Get search filter |
||
103 | * |
||
104 | * @return SearchFilter |
||
105 | */ |
||
106 | 4 | protected function getSearchFilter() |
|
114 | |||
115 | /** |
||
116 | * Get the plural name of the entity |
||
117 | * |
||
118 | * @return string |
||
119 | */ |
||
120 | 4 | protected function getEntityNamePlural() |
|
131 | |||
132 | /** |
||
133 | * Gets updated HTTP request |
||
134 | * |
||
135 | * @return ServerRequestInterface|Request |
||
136 | */ |
||
137 | abstract public function getRequest(); |
||
138 | |||
139 | /** |
||
140 | * Sets a value to be used by render |
||
141 | * |
||
142 | * The key argument can be an associative array with values to be set |
||
143 | * or a string naming the passed value. If an array is given then the |
||
144 | * value will be ignored. |
||
145 | * |
||
146 | * Those values must be set in the request attributes so they can be used |
||
147 | * latter by any other middle ware in the stack. |
||
148 | * |
||
149 | * @param string|array $key |
||
150 | * @param mixed $value |
||
151 | * |
||
152 | * @return ControllerInterface |
||
153 | */ |
||
154 | abstract public function set($key, $value = null); |
||
155 | |||
156 | /** |
||
157 | * Gets the entity FQ class name |
||
158 | * |
||
159 | * @return string |
||
160 | */ |
||
161 | abstract protected function getEntityClassName(); |
||
162 | |||
163 | /** |
||
164 | * Get the fields list to use on search filter |
||
165 | * |
||
166 | * @return array|\string[] |
||
167 | */ |
||
168 | 2 | protected function getSearchFields() |
|
182 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: