1 | <?php |
||
13 | class Menu |
||
14 | { |
||
15 | |||
16 | // the route name |
||
17 | protected $route; |
||
18 | |||
19 | // the title option |
||
20 | protected $title; |
||
21 | |||
22 | // the url option |
||
23 | protected $link = [ |
||
24 | 'new_tab' => false, |
||
25 | 'value' => null, |
||
26 | 'regex' => [] |
||
27 | ]; |
||
28 | |||
29 | // the class-name option |
||
30 | protected $class; |
||
31 | |||
32 | // the icon option |
||
33 | protected $icon = [ |
||
34 | 'tag' => 'i', |
||
35 | 'value' => null |
||
36 | ]; |
||
37 | |||
38 | // is_new icon option : boolean |
||
39 | protected $isNew = false; |
||
40 | |||
41 | // selected option |
||
42 | protected $selected = false; |
||
43 | |||
44 | // open child when item is active : boolean |
||
45 | protected $openChildOnClick = true; |
||
46 | |||
47 | // the sub menu array |
||
48 | protected $submenu = []; |
||
49 | |||
50 | /** |
||
51 | * Attach sub menu array |
||
52 | * |
||
53 | * @author Alireza Josheghani <[email protected]> |
||
54 | * @since 20 Sep 2016 |
||
55 | * @param $route |
||
56 | * @param $callback |
||
57 | */ |
||
58 | public function sub($route, $callback) |
||
63 | |||
64 | /** |
||
65 | * Attach sub menu array with checking status of item |
||
66 | * |
||
67 | * @author Alireza Josheghani <[email protected]> |
||
68 | * @since 20 Sep 2016 |
||
69 | * @param $route |
||
70 | * @param $callback |
||
71 | * @param $checkCallback |
||
72 | */ |
||
73 | public function subWithCheck($route, $callback , $checkCallback) |
||
80 | |||
81 | /** |
||
82 | * Set the icon option |
||
83 | * |
||
84 | * @author Alireza Josheghani <[email protected]> |
||
85 | * @since 20 Sep 2016 |
||
86 | * @param $icon |
||
87 | */ |
||
88 | public function icon($icon) |
||
93 | |||
94 | /** |
||
95 | * Set the icon tag option |
||
96 | * |
||
97 | * @author Alireza Josheghani <[email protected]> |
||
98 | * @since 20 Sep 2016 |
||
99 | * @param $icon |
||
100 | */ |
||
101 | public function tag($tag) |
||
106 | |||
107 | /** |
||
108 | * Set the title option |
||
109 | * |
||
110 | * @author Alireza Josheghani <[email protected]> |
||
111 | * @since 20 Sep 2016 |
||
112 | * @param $title |
||
113 | */ |
||
114 | public function title($title) |
||
118 | |||
119 | /** |
||
120 | * Set the class-name option |
||
121 | * |
||
122 | * @author Alireza Josheghani <[email protected]> |
||
123 | * @since 20 Sep 2016 |
||
124 | * @param $class_name |
||
125 | */ |
||
126 | public function className($className) |
||
130 | |||
131 | /** |
||
132 | * Set the newTab option |
||
133 | * |
||
134 | * @author Alireza Josheghani <[email protected]> |
||
135 | * @since 20 Sep 2016 |
||
136 | * @param $newtab : boolean |
||
137 | */ |
||
138 | public function newTab($newtab) |
||
142 | |||
143 | /** |
||
144 | * Set route name |
||
145 | * |
||
146 | * @author Alireza Josheghani <[email protected]> |
||
147 | * @since 20 Sep 2016 |
||
148 | * @param $route |
||
149 | */ |
||
150 | public function routeName($route) |
||
154 | |||
155 | /** |
||
156 | * Set the link of menu |
||
157 | * |
||
158 | * @author Alireza Josheghani <[email protected]> |
||
159 | * @since 20 Sep 2016 |
||
160 | * @param $link |
||
161 | */ |
||
162 | public function link($link) |
||
166 | |||
167 | /** |
||
168 | * Set the regex link of menu |
||
169 | * |
||
170 | * @author Alireza Josheghani <[email protected]> |
||
171 | * @since 16 Oxt 2016 |
||
172 | * @param array $regex |
||
173 | */ |
||
174 | public function regex(array $regex) |
||
178 | |||
179 | /** |
||
180 | * Set target link of item |
||
181 | * |
||
182 | * @author Alireza Josheghani <[email protected]> |
||
183 | * @since 20 Sep 2016 |
||
184 | * @param $isNew |
||
185 | */ |
||
186 | public function isNew($isNew) |
||
190 | |||
191 | /** |
||
192 | * Set item is selected |
||
193 | * |
||
194 | * @author Alireza Josheghani <[email protected]> |
||
195 | * @since 20 Sep 2016 |
||
196 | * @param $type |
||
197 | */ |
||
198 | public function selected($type) |
||
202 | |||
203 | /** |
||
204 | * Set open child when item is active |
||
205 | * |
||
206 | * @author Alireza Josheghani <[email protected]> |
||
207 | * @since 20 Sep 2016 |
||
208 | * @param $type |
||
209 | */ |
||
210 | public function openChildOnClick($type) |
||
214 | |||
215 | /** |
||
216 | * make the return item array |
||
217 | * |
||
218 | * @author Alireza Josheghani <[email protected]> |
||
219 | * @since 20 Sep 2016 |
||
220 | * @return array |
||
221 | */ |
||
222 | public function make($route) |
||
253 | |||
254 | } |
||
255 |
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: