1 | <?php |
||
26 | trait EntityListingMethods |
||
27 | { |
||
28 | |||
29 | /** |
||
30 | * @var int |
||
31 | */ |
||
32 | protected $rowsPerPage = 12; |
||
33 | |||
34 | /** |
||
35 | * @var Pagination |
||
36 | */ |
||
37 | protected $pagination; |
||
38 | |||
39 | /** |
||
40 | * @var EntityListingService |
||
41 | */ |
||
42 | protected $listingService; |
||
43 | |||
44 | /** |
||
45 | * @var string[] |
||
46 | */ |
||
47 | protected $searchFields; |
||
48 | |||
49 | /** |
||
50 | * Handle the request to display a list of entities |
||
51 | */ |
||
52 | 2 | public function index() |
|
66 | |||
67 | /** |
||
68 | * Get pagination for roes per page property |
||
69 | * |
||
70 | * @return Pagination |
||
71 | */ |
||
72 | 4 | protected function getPagination() |
|
84 | |||
85 | /** |
||
86 | * Get the entity listing service |
||
87 | * |
||
88 | * @return EntityListingService |
||
89 | */ |
||
90 | 4 | protected function getListingService() |
|
99 | |||
100 | /** |
||
101 | * Get search filter |
||
102 | * |
||
103 | * @return SearchFilter |
||
104 | */ |
||
105 | 4 | protected function getSearchFilter() |
|
113 | |||
114 | /** |
||
115 | * Get the fields list to use on search filter |
||
116 | * |
||
117 | * @return array|\string[] |
||
118 | */ |
||
119 | 2 | protected function getSearchFields() |
|
130 | |||
131 | /** |
||
132 | * Returns the query order by clause |
||
133 | * |
||
134 | * @return string |
||
135 | */ |
||
136 | 2 | protected function getOrder() |
|
144 | |||
145 | /** |
||
146 | * Gets updated HTTP request |
||
147 | * |
||
148 | * @return ServerRequestInterface|Request |
||
149 | */ |
||
150 | abstract public function getRequest(); |
||
151 | |||
152 | /** |
||
153 | * Get the current entity descriptor |
||
154 | * |
||
155 | * @return \Slick\Orm\Descriptor\EntityDescriptorInterface |
||
156 | */ |
||
157 | abstract protected function getEntityDescriptor(); |
||
158 | |||
159 | /** |
||
160 | * Get the plural name of the entity |
||
161 | * |
||
162 | * @return string |
||
163 | */ |
||
164 | abstract protected function getEntityNamePlural(); |
||
165 | } |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.