@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | public function sub($route, $callback) |
54 | 54 | { |
55 | 55 | $sub = SideNav::addSub($route, $callback); |
56 | - array_push($this->submenu,$sub); |
|
56 | + array_push($this->submenu, $sub); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function subWithCheckStatus($route, $callback) |
65 | 65 | { |
66 | - if(SideNav::checkStatus($route) === true){ |
|
66 | + if (SideNav::checkStatus($route) === true) { |
|
67 | 67 | $sub = SideNav::addSub($route, $callback); |
68 | - array_push($this->submenu,$sub); |
|
68 | + array_push($this->submenu, $sub); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | |
175 | 175 | $submenu = null; |
176 | 176 | |
177 | - if(!empty($this->submenu)) |
|
177 | + if (!empty($this->submenu)) |
|
178 | 178 | $submenu = $this->submenu; |
179 | 179 | |
180 | 180 | $result = [ |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | 'sub' => $submenu |
190 | 190 | ]; |
191 | 191 | |
192 | - if(empty($this->submenu)) |
|
192 | + if (empty($this->submenu)) |
|
193 | 193 | unset($result['sub']); |
194 | 194 | |
195 | 195 | return $result; |
@@ -174,8 +174,9 @@ discard block |
||
174 | 174 | |
175 | 175 | $submenu = null; |
176 | 176 | |
177 | - if(!empty($this->submenu)) |
|
178 | - $submenu = $this->submenu; |
|
177 | + if(!empty($this->submenu)) { |
|
178 | + $submenu = $this->submenu; |
|
179 | + } |
|
179 | 180 | |
180 | 181 | $result = [ |
181 | 182 | 'name' => $this->route, |
@@ -189,8 +190,9 @@ discard block |
||
189 | 190 | 'sub' => $submenu |
190 | 191 | ]; |
191 | 192 | |
192 | - if(empty($this->submenu)) |
|
193 | - unset($result['sub']); |
|
193 | + if(empty($this->submenu)) { |
|
194 | + unset($result['sub']); |
|
195 | + } |
|
194 | 196 | |
195 | 197 | return $result; |
196 | 198 |
@@ -8,44 +8,44 @@ |
||
8 | 8 | * SideNav helper functions |
9 | 9 | */ |
10 | 10 | |
11 | -if(! function_exists('hasSub')){ |
|
11 | +if (!function_exists('hasSub')) { |
|
12 | 12 | /** |
13 | 13 | * Check menu has sub |
14 | 14 | * @param $menu |
15 | 15 | * @return bool |
16 | 16 | */ |
17 | - function hasSub($menu){ |
|
18 | - if(! empty($menu['sub'])) |
|
17 | + function hasSub($menu) { |
|
18 | + if (!empty($menu['sub'])) |
|
19 | 19 | return true; |
20 | 20 | return false; |
21 | 21 | } |
22 | 22 | } |
23 | 23 | |
24 | -if(! function_exists('icon')){ |
|
24 | +if (!function_exists('icon')) { |
|
25 | 25 | /** |
26 | 26 | * Print item icon |
27 | 27 | * @param $value |
28 | 28 | * @return string |
29 | 29 | */ |
30 | - function itemIcon($value){ |
|
30 | + function itemIcon($value) { |
|
31 | 31 | |
32 | 32 | $tag = $value['tag']; |
33 | 33 | |
34 | - if($value['tag'] === null) |
|
34 | + if ($value['tag'] === null) |
|
35 | 35 | $tag = 'i'; |
36 | 36 | |
37 | 37 | return '<' . $tag . ' class="' . $value['value'] . '"></' . $tag . '>'; |
38 | 38 | } |
39 | 39 | } |
40 | 40 | |
41 | -if(! function_exists('new_tab')){ |
|
41 | +if (!function_exists('new_tab')) { |
|
42 | 42 | /** |
43 | 43 | * Print item new_tab option |
44 | 44 | * @param $newTab |
45 | 45 | * @return null|string |
46 | 46 | */ |
47 | - function new_tab($newTab){ |
|
48 | - if($newTab) |
|
47 | + function new_tab($newTab) { |
|
48 | + if ($newTab) |
|
49 | 49 | return 'target="_blank"'; |
50 | 50 | |
51 | 51 | return null; |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @return bool |
16 | 16 | */ |
17 | 17 | function hasSub($menu){ |
18 | - if(! empty($menu['sub'])) |
|
19 | - return true; |
|
18 | + if(! empty($menu['sub'])) { |
|
19 | + return true; |
|
20 | + } |
|
20 | 21 | return false; |
21 | 22 | } |
22 | 23 | } |
@@ -31,8 +32,9 @@ discard block |
||
31 | 32 | |
32 | 33 | $tag = $value['tag']; |
33 | 34 | |
34 | - if($value['tag'] === null) |
|
35 | - $tag = 'i'; |
|
35 | + if($value['tag'] === null) { |
|
36 | + $tag = 'i'; |
|
37 | + } |
|
36 | 38 | |
37 | 39 | return '<' . $tag . ' class="' . $value['value'] . '"></' . $tag . '>'; |
38 | 40 | } |
@@ -45,8 +47,9 @@ discard block |
||
45 | 47 | * @return null|string |
46 | 48 | */ |
47 | 49 | function new_tab($newTab){ |
48 | - if($newTab) |
|
49 | - return 'target="_blank"'; |
|
50 | + if($newTab) { |
|
51 | + return 'target="_blank"'; |
|
52 | + } |
|
50 | 53 | |
51 | 54 | return null; |
52 | 55 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | self::$routes[self::$current_route] = []; |
78 | 78 | |
79 | 79 | // make menu array |
80 | - $array = self::add($route,$callback); |
|
80 | + $array = self::add($route, $callback); |
|
81 | 81 | |
82 | 82 | if (self::checkGroupId(self::$type)) |
83 | 83 | // add to the group render array |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | public static function addSub($route, $callback) |
111 | 111 | { |
112 | 112 | // register route name |
113 | - array_push(self::$routes[self::$current_route],$route); |
|
113 | + array_push(self::$routes[self::$current_route], $route); |
|
114 | 114 | |
115 | 115 | // return submenu array |
116 | - return self::add($route,$callback); |
|
116 | + return self::add($route, $callback); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @param $callback |
123 | 123 | * @return array |
124 | 124 | */ |
125 | - private static function add($route,$callback) |
|
125 | + private static function add($route, $callback) |
|
126 | 126 | { |
127 | 127 | // instance of menu class |
128 | 128 | $menu = new Menu; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | public static function routes() |
142 | 142 | { |
143 | 143 | // return json array of all routes-name |
144 | - if(self::$resultType === 'json') |
|
144 | + if (self::$resultType === 'json') |
|
145 | 145 | return json_encode(self::$routes); |
146 | 146 | |
147 | 147 | // return array of all routes-name |
@@ -160,10 +160,10 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public static function render($type = null) |
162 | 162 | { |
163 | - if(self::checkGroupId($type)) { |
|
163 | + if (self::checkGroupId($type)) { |
|
164 | 164 | |
165 | 165 | // render the menu json array |
166 | - if(self::$resultType === 'json') |
|
166 | + if (self::$resultType === 'json') |
|
167 | 167 | return json_encode(self::$menu[$type]); |
168 | 168 | |
169 | 169 | // render the menu array |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | } |
172 | 172 | |
173 | 173 | // return single menu json array |
174 | - if(self::$resultType === 'json') |
|
174 | + if (self::$resultType === 'json') |
|
175 | 175 | return json_encode(self::$menu); |
176 | 176 | |
177 | 177 | // return single menu array |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public static function checkGroupId($type) |
186 | 186 | { |
187 | - if($type !== null && isset(self::$type)) |
|
187 | + if ($type !== null && isset(self::$type)) |
|
188 | 188 | return true; |
189 | 189 | |
190 | 190 | return false; |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | { |
200 | 200 | $obj = self::$checkStatusObject; |
201 | 201 | |
202 | - if(class_exists($obj)) { |
|
202 | + if (class_exists($obj)) { |
|
203 | 203 | $class = new $obj; |
204 | 204 | if ($class->handle($route)) |
205 | 205 | return true; |
@@ -79,9 +79,10 @@ discard block |
||
79 | 79 | // make menu array |
80 | 80 | $array = self::add($route,$callback); |
81 | 81 | |
82 | - if (self::checkGroupId(self::$type)) |
|
83 | - // add to the group render array |
|
82 | + if (self::checkGroupId(self::$type)) { |
|
83 | + // add to the group render array |
|
84 | 84 | array_push(self::$menu[self::$type], $array); |
85 | + } |
|
85 | 86 | |
86 | 87 | // add to the single render array |
87 | 88 | array_push(self::$menu, $array); |
@@ -141,8 +142,9 @@ discard block |
||
141 | 142 | public static function routes() |
142 | 143 | { |
143 | 144 | // return json array of all routes-name |
144 | - if(self::$resultType === 'json') |
|
145 | - return json_encode(self::$routes); |
|
145 | + if(self::$resultType === 'json') { |
|
146 | + return json_encode(self::$routes); |
|
147 | + } |
|
146 | 148 | |
147 | 149 | // return array of all routes-name |
148 | 150 | return self::$routes; |
@@ -163,16 +165,18 @@ discard block |
||
163 | 165 | if(self::checkGroupId($type)) { |
164 | 166 | |
165 | 167 | // render the menu json array |
166 | - if(self::$resultType === 'json') |
|
167 | - return json_encode(self::$menu[$type]); |
|
168 | + if(self::$resultType === 'json') { |
|
169 | + return json_encode(self::$menu[$type]); |
|
170 | + } |
|
168 | 171 | |
169 | 172 | // render the menu array |
170 | 173 | return self::$menu[$type]; |
171 | 174 | } |
172 | 175 | |
173 | 176 | // return single menu json array |
174 | - if(self::$resultType === 'json') |
|
175 | - return json_encode(self::$menu); |
|
177 | + if(self::$resultType === 'json') { |
|
178 | + return json_encode(self::$menu); |
|
179 | + } |
|
176 | 180 | |
177 | 181 | // return single menu array |
178 | 182 | return self::$menu; |
@@ -184,8 +188,9 @@ discard block |
||
184 | 188 | */ |
185 | 189 | public static function checkGroupId($type) |
186 | 190 | { |
187 | - if($type !== null && isset(self::$type)) |
|
188 | - return true; |
|
191 | + if($type !== null && isset(self::$type)) { |
|
192 | + return true; |
|
193 | + } |
|
189 | 194 | |
190 | 195 | return false; |
191 | 196 | } |
@@ -201,8 +206,9 @@ discard block |
||
201 | 206 | |
202 | 207 | if(class_exists($obj)) { |
203 | 208 | $class = new $obj; |
204 | - if ($class->handle($route)) |
|
205 | - return true; |
|
209 | + if ($class->handle($route)) { |
|
210 | + return true; |
|
211 | + } |
|
206 | 212 | return false; |
207 | 213 | } |
208 | 214 |