1 | <?php |
||
11 | class MenuItem |
||
12 | { |
||
13 | /** |
||
14 | * The properties array. |
||
15 | * |
||
16 | * @var array |
||
17 | */ |
||
18 | public $properties = []; |
||
19 | |||
20 | /** |
||
21 | * The childs collection. |
||
22 | * |
||
23 | * @var \Illuminate\Support\Collection |
||
24 | */ |
||
25 | protected $childs; |
||
26 | |||
27 | /** |
||
28 | * The hide callback. |
||
29 | * |
||
30 | * @var callable |
||
31 | */ |
||
32 | protected $hideWhen; |
||
33 | |||
34 | /** |
||
35 | * The active callback. |
||
36 | * |
||
37 | * @var callable |
||
38 | */ |
||
39 | protected $activeWhen; |
||
40 | |||
41 | /** |
||
42 | * Constructor. |
||
43 | * |
||
44 | * @param array $properties |
||
45 | */ |
||
46 | public function __construct($properties = []) |
||
51 | |||
52 | /** |
||
53 | * Get property. |
||
54 | * |
||
55 | * @param string $key |
||
56 | * |
||
57 | * @return mixed |
||
58 | */ |
||
59 | public function __get($key) |
||
63 | |||
64 | /** |
||
65 | * Fill the properties. |
||
66 | * |
||
67 | * @param array $properties |
||
68 | * |
||
69 | * @return static |
||
70 | */ |
||
71 | public function fill($properties) |
||
77 | |||
78 | /** |
||
79 | * Create new menu with dropdown. |
||
80 | * |
||
81 | * @param callable $callback |
||
82 | * @param string $title |
||
83 | * @param int $order |
||
|
|||
84 | * @param string $icon |
||
85 | * @param array $attributes |
||
86 | * |
||
87 | * @return static |
||
88 | */ |
||
89 | public function dropdown(callable $callback, string $title, int $order = null, string $icon = null, array $attributes = []) |
||
95 | |||
96 | /** |
||
97 | * Register new menu item using registered route. |
||
98 | * |
||
99 | * @param string $route |
||
100 | * @param string $title |
||
101 | * @param int $order |
||
102 | * @param string $icon |
||
103 | * @param array $attributes |
||
104 | * |
||
105 | * @return static |
||
106 | */ |
||
107 | public function route(array $route, string $title, int $order = null, string $icon = null, array $attributes = []) |
||
111 | |||
112 | /** |
||
113 | * Register new menu item using url. |
||
114 | * |
||
115 | * @param string $url |
||
116 | * @param string $title |
||
117 | * @param int $order |
||
118 | * @param string $icon |
||
119 | * @param array $attributes |
||
120 | * |
||
121 | * @return static |
||
122 | */ |
||
123 | public function url(string $url, string $title, int $order = null, string $icon = null, array $attributes = []) |
||
127 | |||
128 | /** |
||
129 | * Add new header item. |
||
130 | * |
||
131 | * @param string $title |
||
132 | * @param int $order |
||
133 | * @param string $icon |
||
134 | * @param array $attributes |
||
135 | * |
||
136 | * @return static |
||
137 | */ |
||
138 | public function header(string $title, int $order = null, string $icon = null, array $attributes = []) |
||
144 | |||
145 | /** |
||
146 | * Add new divider item. |
||
147 | * |
||
148 | * @param int $order |
||
149 | * @param array $attributes |
||
150 | * |
||
151 | * @return static |
||
152 | */ |
||
153 | public function divider(int $order = null, array $attributes = []) |
||
157 | |||
158 | /** |
||
159 | * Get childs. |
||
160 | * |
||
161 | * @return \Illuminate\Support\Collection |
||
162 | */ |
||
163 | public function getChilds() |
||
167 | |||
168 | /** |
||
169 | * Get url. |
||
170 | * |
||
171 | * @return string |
||
172 | */ |
||
173 | public function getUrl() |
||
177 | |||
178 | /** |
||
179 | * Get HTML attribute data. |
||
180 | * |
||
181 | * @return mixed |
||
182 | */ |
||
183 | public function getAttributes() |
||
187 | |||
188 | /** |
||
189 | * Check if the current item is divider. |
||
190 | * |
||
191 | * @return bool |
||
192 | */ |
||
193 | public function isDivider(): bool |
||
197 | |||
198 | /** |
||
199 | * Check if the current item is header. |
||
200 | * |
||
201 | * @return bool |
||
202 | */ |
||
203 | public function isHeader(): bool |
||
207 | |||
208 | /** |
||
209 | * Check is the current item has sub menu . |
||
210 | * |
||
211 | * @return bool |
||
212 | */ |
||
213 | public function hasChilds() |
||
217 | |||
218 | /** |
||
219 | * Check the active state for current menu. |
||
220 | * |
||
221 | * @return bool |
||
222 | */ |
||
223 | public function hasActiveOnChild() |
||
227 | |||
228 | /** |
||
229 | * Set hide callback for current menu item. |
||
230 | * |
||
231 | * @param callable $callback |
||
232 | * |
||
233 | * @return $this |
||
234 | */ |
||
235 | public function hideWhen(callable $callback) |
||
241 | |||
242 | /** |
||
243 | * Set authorization callback for current menu item. |
||
244 | * |
||
245 | * @param string $ability |
||
246 | * @param mixed $params |
||
247 | * |
||
248 | * @return $this |
||
249 | */ |
||
250 | public function ifCan(string $ability, $params = null) |
||
258 | |||
259 | /** |
||
260 | * Set authentication callback for current menu item. |
||
261 | * |
||
262 | * @return $this |
||
263 | */ |
||
264 | public function ifUser() |
||
272 | |||
273 | /** |
||
274 | * Set authentication callback for current menu item. |
||
275 | * |
||
276 | * @return $this |
||
277 | */ |
||
278 | public function ifGuest() |
||
286 | |||
287 | /** |
||
288 | * Check if the menu item is hidden. |
||
289 | * |
||
290 | * @return bool |
||
291 | */ |
||
292 | public function isHidden() |
||
296 | |||
297 | /** |
||
298 | * Get active state for current item. |
||
299 | * |
||
300 | * @return bool |
||
301 | */ |
||
302 | public function isActive() |
||
314 | |||
315 | /** |
||
316 | * Set active callback. |
||
317 | * |
||
318 | * @param callable $route |
||
319 | * |
||
320 | * @return $this |
||
321 | */ |
||
322 | public function activateWhen(callable $callback) |
||
328 | |||
329 | /** |
||
330 | * Set active callback on the given route. |
||
331 | * |
||
332 | * @param string $route |
||
333 | * |
||
334 | * @return $this |
||
335 | */ |
||
336 | public function activateOnRoute(string $route) |
||
344 | |||
345 | /** |
||
346 | * Add new child item. |
||
347 | * |
||
348 | * @param array $properties |
||
349 | * |
||
350 | * @return static |
||
351 | */ |
||
352 | protected function add(array $properties = []) |
||
359 | |||
360 | /** |
||
361 | * Get active status using route. |
||
362 | * |
||
363 | * @return bool |
||
364 | */ |
||
365 | protected function hasActiveStateFromRoute(): bool |
||
369 | |||
370 | /** |
||
371 | * Get active status using request url. |
||
372 | * |
||
373 | * @return bool |
||
374 | */ |
||
375 | protected function hasActiveStateFromUrl(): bool |
||
379 | |||
380 | /** |
||
381 | * Check if the item has active state from childs. |
||
382 | * |
||
383 | * @return bool |
||
384 | */ |
||
385 | protected function hasActiveStateFromChilds(): bool |
||
393 | } |
||
394 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.