@@ -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,13 +140,13 @@ 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 | |
147 | 147 | $this->hasProtocol($route, $currentProtocol); |
148 | 148 | |
149 | - $route_loop = explode( |
|
149 | + $route_loop = explode( |
|
150 | 150 | '/', |
151 | 151 | (substr($route['url'],strlen($route['url'])-1,1) === '/') |
152 | 152 | ? substr($route['url'], 0, -1) |
@@ -160,17 +160,17 @@ discard block |
||
160 | 160 | : $_SERVER['REQUEST_URI'] |
161 | 161 | ); |
162 | 162 | |
163 | - if($this->check_numparams($route_loop, $route_request) || $this->check_parameters($route_loop, $route_request)){ |
|
163 | + if($this->check_numparams($route_loop, $route_request) || $this->check_parameters($route_loop, $route_request)){ |
|
164 | 164 | continue; |
165 | 165 | } |
166 | 166 | |
167 | 167 | $this->check_filtering($route); |
168 | 168 | |
169 | 169 | $this->Controller($route['role']); |
170 | - return true; |
|
171 | - } |
|
170 | + return true; |
|
171 | + } |
|
172 | 172 | |
173 | - throw new Exception('Page not found.',404); |
|
173 | + throw new Exception('Page not found.',404); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | public static function filter($filters): Router |