@@ -217,7 +217,7 @@ |
||
| 217 | 217 | foreach ($route['filters'] as $key => $value) { |
| 218 | 218 | $filters[] = $value; |
| 219 | 219 | } |
| 220 | - }else{ |
|
| 220 | + } else{ |
|
| 221 | 221 | $filters[] = $route['filters']; |
| 222 | 222 | } |
| 223 | 223 | |
@@ -89,25 +89,25 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | public function set($url ,$walking , string $protocol): Router |
| 91 | 91 | { |
| 92 | - $url = (substr($url,0,1) !=='/' and strlen($url) > 0) ? "/{$url}" : $url; |
|
| 92 | + $url = (substr($url,0,1) !=='/' and strlen($url) > 0) ? "/{$url}" : $url; |
|
| 93 | 93 | |
| 94 | - foreach($this->routers as $key => $value){ |
|
| 95 | - if( md5($this->prefix . $value['url'] . $value['protocol'] ) === md5( $url . $protocol ) ){ |
|
| 94 | + foreach($this->routers as $key => $value){ |
|
| 95 | + if( md5($this->prefix . $value['url'] . $value['protocol'] ) === md5( $url . $protocol ) ){ |
|
| 96 | 96 | throw new Exception("There is already a route with the url {$url} and with the {$protocol} protocol configured."); |
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | $this->checkTypeRole($walking); |
| 101 | 101 | |
| 102 | - $route = [ |
|
| 103 | - 'url' => $this->prefix.$url, |
|
| 104 | - 'role' => $walking, |
|
| 105 | - 'protocol' => $protocol, |
|
| 106 | - 'filters' => null, |
|
| 102 | + $route = [ |
|
| 103 | + 'url' => $this->prefix.$url, |
|
| 104 | + 'role' => $walking, |
|
| 105 | + 'protocol' => $protocol, |
|
| 106 | + 'filters' => null, |
|
| 107 | 107 | 'group' => self::getInstance()->group |
| 108 | - ]; |
|
| 108 | + ]; |
|
| 109 | 109 | |
| 110 | - $this->routers[] = $route; |
|
| 110 | + $this->routers[] = $route; |
|
| 111 | 111 | |
| 112 | 112 | return self::getInstance(); |
| 113 | 113 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | $instance->getInstance()->byName($routeName); |
| 174 | 174 | |
| 175 | - $currentProtocol = $instance->getInstance()->getProtocol(); |
|
| 175 | + $currentProtocol = $instance->getInstance()->getProtocol(); |
|
| 176 | 176 | |
| 177 | 177 | foreach(array_reverse($instance->getInstance()->routers) as $r => $route){ |
| 178 | 178 | |
@@ -190,19 +190,19 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | $routeRequest = $instance->getInstance()->explodeRoute((substr($_SERVER['REQUEST_URI'],strlen($_SERVER['REQUEST_URI'])-1,1) === '/') , $_SERVER['REQUEST_URI']); |
| 192 | 192 | |
| 193 | - if($instance->getInstance()->checkNumparams($routeLoop, $routeRequest) || !$instance->getInstance()->checkParameters($routeLoop, $routeRequest)){ |
|
| 193 | + if($instance->getInstance()->checkNumparams($routeLoop, $routeRequest) || !$instance->getInstance()->checkParameters($routeLoop, $routeRequest)){ |
|
| 194 | 194 | continue; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | $instance->getInstance()->checkFiltering($route); |
| 198 | 198 | |
| 199 | 199 | $instance->getInstance()->toHiking($route['role']); |
| 200 | - return true; |
|
| 200 | + return true; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | $instance->getInstance()->currentRoute = null; |
| 204 | 204 | |
| 205 | - throw new Exception('Page not found.',404); |
|
| 205 | + throw new Exception('Page not found.',404); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | public static function filter($filters): Router |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | /* Return current action route */ |
| 21 | 21 | $action = Router::currentRouteAction(); |
| 22 | 22 | |
| 23 | -}catch(Exception $er){ |
|
| 23 | +} catch(Exception $er){ |
|
| 24 | 24 | |
| 25 | 25 | die("Code Error: {$er->getCode()}, Line: {$er->getLine()}, File: {$er->getFile()}, Message: {$er->getMessage()}."); |
| 26 | 26 | |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | |
| 61 | 61 | if( ($this->getProtocol() == 'form') ){ |
| 62 | 62 | $this->ControllerForm($controller, $method, $data['POST']); |
| 63 | - }else { |
|
| 63 | + } else { |
|
| 64 | 64 | $data = (array_key_exists('data',$data['POST'])) ? json_decode($data['POST']['data'], true) : $data['GET']; |
| 65 | 65 | call_user_func_array([$controller,$method], $data); |
| 66 | 66 | } |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | protected function ControllerForm($controller, string $method, array $values){ |
| 53 | - $this->checkRole(); |
|
| 53 | + $this->checkRole(); |
|
| 54 | 54 | $method = ($method !== 'method') ? $method : $this->getData()['POST']['role']; |
| 55 | 55 | $data = (array_key_exists('data',$values)) ? json_decode($values['data'], true) : null; |
| 56 | 56 | |