1 | <?php |
||
13 | class MenuItem |
||
14 | { |
||
15 | /** |
||
16 | * The properties array. |
||
17 | * |
||
18 | * @var array |
||
19 | */ |
||
20 | public $properties = []; |
||
21 | |||
22 | /** |
||
23 | * The childs collection. |
||
24 | * |
||
25 | * @var \Illuminate\Support\Collection |
||
26 | */ |
||
27 | protected $childs; |
||
28 | |||
29 | /** |
||
30 | * The hide callbacks collection. |
||
31 | * |
||
32 | * @var \Illuminate\Support\Collection |
||
33 | */ |
||
34 | protected $hideCallbacks; |
||
35 | |||
36 | /** |
||
37 | * The active callback. |
||
38 | * |
||
39 | * @var callable |
||
40 | */ |
||
41 | protected $activeWhen; |
||
42 | |||
43 | /** |
||
44 | * Constructor. |
||
45 | * |
||
46 | * @param array $properties |
||
47 | */ |
||
48 | public function __construct($properties = []) |
||
55 | |||
56 | /** |
||
57 | * Get property. |
||
58 | * |
||
59 | * @param string $key |
||
60 | * |
||
61 | * @return mixed |
||
62 | */ |
||
63 | public function __get($key) |
||
67 | |||
68 | /** |
||
69 | * Fill the properties. |
||
70 | * |
||
71 | * @param array $properties |
||
72 | * |
||
73 | * @return static |
||
74 | */ |
||
75 | public function fill($properties) |
||
81 | |||
82 | /** |
||
83 | * Add new child item. |
||
84 | * |
||
85 | * @param array $properties |
||
86 | * |
||
87 | * @return static |
||
88 | */ |
||
89 | protected function add(array $properties = []) |
||
96 | |||
97 | /** |
||
98 | * Create new menu with dropdown. |
||
99 | * |
||
100 | * @param callable $callback |
||
101 | * @param string $title |
||
102 | * @param int $order |
||
|
|||
103 | * @param string $icon |
||
104 | * @param array $attributes |
||
105 | * |
||
106 | * @return static |
||
107 | */ |
||
108 | public function dropdown(callable $callback, string $title, int $order = null, string $icon = null, array $attributes = []) |
||
116 | |||
117 | /** |
||
118 | * Register new menu item using registered route. |
||
119 | * |
||
120 | * @param string $route |
||
121 | * @param string $title |
||
122 | * @param int $order |
||
123 | * @param string $icon |
||
124 | * @param array $attributes |
||
125 | * |
||
126 | * @return static |
||
127 | */ |
||
128 | public function route(array $route, string $title, int $order = null, string $icon = null, array $attributes = []) |
||
134 | |||
135 | /** |
||
136 | * Register new menu item using url. |
||
137 | * |
||
138 | * @param string $url |
||
139 | * @param string $title |
||
140 | * @param int $order |
||
141 | * @param string $icon |
||
142 | * @param array $attributes |
||
143 | * |
||
144 | * @return static |
||
145 | */ |
||
146 | public function url(string $url, string $title, int $order = null, string $icon = null, array $attributes = []) |
||
152 | |||
153 | /** |
||
154 | * Add new header item. |
||
155 | * |
||
156 | * @param string $title |
||
157 | * @param int $order |
||
158 | * @param string $icon |
||
159 | * @param array $attributes |
||
160 | * |
||
161 | * @return static |
||
162 | */ |
||
163 | public function header(string $title, int $order = null, string $icon = null, array $attributes = []) |
||
169 | |||
170 | /** |
||
171 | * Add new divider item. |
||
172 | * |
||
173 | * @param int $order |
||
174 | * @param array $attributes |
||
175 | * |
||
176 | * @return static |
||
177 | */ |
||
178 | public function divider(int $order = null, array $attributes = []) |
||
184 | |||
185 | /** |
||
186 | * Get childs. |
||
187 | * |
||
188 | * @return \Illuminate\Support\Collection |
||
189 | */ |
||
190 | public function getChilds(): Collection |
||
194 | |||
195 | /** |
||
196 | * Get url. |
||
197 | * |
||
198 | * @return string |
||
199 | */ |
||
200 | public function getUrl(): string |
||
204 | |||
205 | /** |
||
206 | * Get HTML attribute data. |
||
207 | * |
||
208 | * @return mixed |
||
209 | */ |
||
210 | public function getAttributes() |
||
214 | |||
215 | /** |
||
216 | * Check if the current item is divider. |
||
217 | * |
||
218 | * @return bool |
||
219 | */ |
||
220 | public function isDivider(): bool |
||
224 | |||
225 | /** |
||
226 | * Check if the current item is header. |
||
227 | * |
||
228 | * @return bool |
||
229 | */ |
||
230 | public function isHeader(): bool |
||
234 | |||
235 | /** |
||
236 | * Check is the current item has sub menu . |
||
237 | * |
||
238 | * @return bool |
||
239 | */ |
||
240 | public function hasChilds(): bool |
||
244 | |||
245 | /** |
||
246 | * Check the active state for current menu. |
||
247 | * |
||
248 | * @return bool |
||
249 | */ |
||
250 | public function hasActiveOnChild(): bool |
||
254 | |||
255 | /** |
||
256 | * Set hide callback for current menu item. |
||
257 | * |
||
258 | * @param callable $callback |
||
259 | * |
||
260 | * @return $this |
||
261 | */ |
||
262 | public function hideWhen(callable $callback) |
||
268 | |||
269 | /** |
||
270 | * Set authorization callback for current menu item. |
||
271 | * |
||
272 | * @param string $ability |
||
273 | * @param mixed $params |
||
274 | * @param string $guard |
||
275 | * |
||
276 | * @return $this |
||
277 | */ |
||
278 | public function ifCan(string $ability, $params = null, $guard = null) |
||
286 | |||
287 | /** |
||
288 | * Set condition callback for current menu item. |
||
289 | * |
||
290 | * @param mixed $condition |
||
291 | * |
||
292 | * @return $this |
||
293 | */ |
||
294 | public function if($condition) |
||
302 | |||
303 | /** |
||
304 | * Set authentication callback for current menu item. |
||
305 | * |
||
306 | * @param string $guard |
||
307 | * |
||
308 | * @return $this |
||
309 | */ |
||
310 | public function ifUser($guard = null) |
||
318 | |||
319 | /** |
||
320 | * Set authentication callback for current menu item. |
||
321 | * |
||
322 | * @param string $guard |
||
323 | * |
||
324 | * @return $this |
||
325 | */ |
||
326 | public function ifGuest($guard = null) |
||
334 | |||
335 | /** |
||
336 | * Check if the menu item is hidden. |
||
337 | * |
||
338 | * @return bool |
||
339 | */ |
||
340 | public function isHidden(): bool |
||
346 | |||
347 | /** |
||
348 | * Get active state for current item. |
||
349 | * |
||
350 | * @return bool |
||
351 | */ |
||
352 | public function isActive(): bool |
||
364 | |||
365 | /** |
||
366 | * Set active callback. |
||
367 | * |
||
368 | * @param callable $route |
||
369 | * |
||
370 | * @return $this |
||
371 | */ |
||
372 | public function activateWhen(callable $callback) |
||
378 | |||
379 | /** |
||
380 | * Set active callback on the given route. |
||
381 | * |
||
382 | * @param string $route |
||
383 | * |
||
384 | * @return $this |
||
385 | */ |
||
386 | public function activateOnRoute(string $route) |
||
394 | |||
395 | /** |
||
396 | * Get active status using route. |
||
397 | * |
||
398 | * @return bool |
||
399 | */ |
||
400 | protected function hasActiveStateFromRoute(): bool |
||
404 | |||
405 | /** |
||
406 | * Get active status using request url. |
||
407 | * |
||
408 | * @return bool |
||
409 | */ |
||
410 | protected function hasActiveStateFromUrl(): bool |
||
414 | |||
415 | /** |
||
416 | * Check if the item has active state from childs. |
||
417 | * |
||
418 | * @return bool |
||
419 | */ |
||
420 | protected function hasActiveStateFromChilds(): bool |
||
428 | } |
||
429 |
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.