@@ -61,23 +61,23 @@ discard block |
||
61 | 61 | |
62 | 62 | public function set($url , $role , $protocol = null): Router |
63 | 63 | { |
64 | - $url = (substr($url,0,1) !=='/' and strlen($url) > 0) ? "/{$url}" : $url; |
|
64 | + $url = (substr($url,0,1) !=='/' and strlen($url) > 0) ? "/{$url}" : $url; |
|
65 | 65 | |
66 | - foreach($this->routers as $key => $value){ |
|
67 | - if( md5($this->prefix . $value['url'] . $value['protocol'] ) === md5( $url . $protocol ) ){ |
|
66 | + foreach($this->routers as $key => $value){ |
|
67 | + if( md5($this->prefix . $value['url'] . $value['protocol'] ) === md5( $url . $protocol ) ){ |
|
68 | 68 | throw new Exception("There is already a route with the url {$url} and with the {$protocol} protocol configured."); |
69 | 69 | } |
70 | - } |
|
70 | + } |
|
71 | 71 | |
72 | - $route = [ |
|
73 | - 'url' => $this->prefix.$url, |
|
74 | - 'role' => $role, |
|
75 | - 'protocol' => $protocol, |
|
76 | - 'filters' => null, |
|
72 | + $route = [ |
|
73 | + 'url' => $this->prefix.$url, |
|
74 | + 'role' => $role, |
|
75 | + 'protocol' => $protocol, |
|
76 | + 'filters' => null, |
|
77 | 77 | 'group' => self::getInstance()->group |
78 | - ]; |
|
78 | + ]; |
|
79 | 79 | |
80 | - $this->routers[] = $route; |
|
80 | + $this->routers[] = $route; |
|
81 | 81 | |
82 | 82 | return self::getInstance(); |
83 | 83 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | { |
141 | 141 | $this->byName($route_name); |
142 | 142 | |
143 | - $currentProtocol = $this->getProtocol(); |
|
143 | + $currentProtocol = $this->getProtocol(); |
|
144 | 144 | |
145 | 145 | foreach(array_reverse($this->routers) as $r => $route){ |
146 | 146 | |
@@ -150,17 +150,17 @@ discard block |
||
150 | 150 | |
151 | 151 | $route_request = $this->explodeRoute((substr($_SERVER['REQUEST_URI'],strlen($_SERVER['REQUEST_URI'])-1,1) === '/') , $_SERVER['REQUEST_URI']); |
152 | 152 | |
153 | - if($this->check_numparams($route_loop, $route_request) || $this->check_parameters($route_loop, $route_request)){ |
|
153 | + if($this->check_numparams($route_loop, $route_request) || $this->check_parameters($route_loop, $route_request)){ |
|
154 | 154 | continue; |
155 | 155 | } |
156 | 156 | |
157 | 157 | $this->check_filtering($route); |
158 | 158 | |
159 | 159 | $this->Controller($route['role']); |
160 | - return true; |
|
161 | - } |
|
160 | + return true; |
|
161 | + } |
|
162 | 162 | |
163 | - throw new Exception('Page not found.',404); |
|
163 | + throw new Exception('Page not found.',404); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | public static function filter($filters): Router |