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() |
|
65 | |||
66 | /** |
||
67 | * Get pagination for roes per page property |
||
68 | * |
||
69 | * @return Pagination |
||
70 | */ |
||
71 | 4 | protected function getPagination() |
|
83 | |||
84 | /** |
||
85 | * Get the entity listing service |
||
86 | * |
||
87 | * @return EntityListingService |
||
88 | */ |
||
89 | 4 | protected function getListingService() |
|
98 | |||
99 | /** |
||
100 | * Get search filter |
||
101 | * |
||
102 | * @return SearchFilter |
||
103 | */ |
||
104 | 4 | protected function getSearchFilter() |
|
112 | |||
113 | /** |
||
114 | * Get the fields list to use on search filter |
||
115 | * |
||
116 | * @return array|\string[] |
||
117 | */ |
||
118 | 2 | protected function getSearchFields() |
|
129 | |||
130 | /** |
||
131 | * Returns the query order by clause |
||
132 | * |
||
133 | * @return string |
||
134 | */ |
||
135 | protected function getOrder() |
||
143 | |||
144 | /** |
||
145 | * Gets updated HTTP request |
||
146 | * |
||
147 | * @return ServerRequestInterface|Request |
||
148 | */ |
||
149 | abstract public function getRequest(); |
||
150 | |||
151 | /** |
||
152 | * Get the current entity descriptor |
||
153 | * |
||
154 | * @return \Slick\Orm\Descriptor\EntityDescriptorInterface |
||
155 | */ |
||
156 | abstract protected function getEntityDescriptor(); |
||
157 | |||
158 | /** |
||
159 | * Get the plural name of the entity |
||
160 | * |
||
161 | * @return string |
||
162 | */ |
||
163 | abstract protected function getEntityNamePlural(); |
||
164 | } |
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.