| @@ -64,19 +64,19 @@ discard block | ||
| 64 | 64 | |
| 65 | 65 | // FIXME: Solve ambiguity here! POST with _method="GET" makes no sense | 
| 66 | 66 | |
| 67 | - if(isset($_POST['_method']) && in_array(strtoupper($_POST['_method']), $validMethods , TRUE)) | |
| 67 | + if (isset($_POST['_method']) && in_array(strtoupper($_POST['_method']), $validMethods, TRUE)) | |
| 68 | 68 | $formMethod = strtoupper($_POST['_method']); | 
| 69 | 69 | |
| 70 | - if(is_null($formMethod)) | |
| 70 | + if (is_null($formMethod)) | |
| 71 | 71 |          { | 
| 72 | 72 | $this->requestMethod = $requestMethod; | 
| 73 | 73 | } | 
| 74 | 74 | else | 
| 75 | 75 |          { | 
| 76 | - if($requestMethod == 'POST') | |
| 76 | + if ($requestMethod == 'POST') | |
| 77 | 77 | $this->requestMethod = $formMethod; | 
| 78 | 78 | |
| 79 | - if(!$this->CI->input->is_ajax_request() && $this->requestMethod == 'HEAD') | |
| 79 | + if (!$this->CI->input->is_ajax_request() && $this->requestMethod == 'HEAD') | |
| 80 | 80 | $this->requestMethod = 'POST'; | 
| 81 | 81 | } | 
| 82 | 82 | } | 
| @@ -90,14 +90,14 @@ discard block | ||
| 90 | 90 | */ | 
| 91 | 91 | public function run() | 
| 92 | 92 |      { | 
| 93 | - if(!$this->route) | |
| 93 | + if (!$this->route) | |
| 94 | 94 |          { | 
| 95 | 95 | //if(is_null(Route::get404())) | 
| 96 | 96 | // show_404(); | 
| 97 | 97 | |
| 98 | - if(Route::get404()->controller != get_class($this->CI)) | |
| 98 | + if (Route::get404()->controller != get_class($this->CI)) | |
| 99 | 99 |              { | 
| 100 | - if(ENVIRONMENT != 'production') | |
| 100 | + if (ENVIRONMENT != 'production') | |
| 101 | 101 |                  { | 
| 102 | 102 |                      show_error('The request method '.$this->requestMethod.' is not allowed to view the resource', 403, 'Forbidden method'); | 
| 103 | 103 | } | 
| @@ -110,7 +110,7 @@ discard block | ||
| 110 | 110 | } | 
| 111 | 111 | else | 
| 112 | 112 |          { | 
| 113 | - if(method_exists($this->CI,$this->route->method)) | |
| 113 | + if (method_exists($this->CI, $this->route->method)) | |
| 114 | 114 |              { | 
| 115 | 115 | $path_args = Route::getRouteArgs($this->route, self::$uri_string); | 
| 116 | 116 | $route_args = Route::compileRoute($this->route)->args; | 
| @@ -119,16 +119,16 @@ discard block | ||
| 119 | 119 | |
| 120 | 120 | // Redirect to 404 if not enough parameters provided | 
| 121 | 121 | |
| 122 | - if(count($path_args) < count($route_args['required'])) | |
| 122 | + if (count($path_args) < count($route_args['required'])) | |
| 123 | 123 | redirect(Route::get404()->path); | 
| 124 | 124 | |
| 125 | - if(count($path_args) == 0) | |
| 125 | + if (count($path_args) == 0) | |
| 126 | 126 |                  { | 
| 127 | 127 |                      $this->CI->{$this->route->method}(); | 
| 128 | 128 | } | 
| 129 | 129 | else | 
| 130 | 130 |                  { | 
| 131 | - call_user_func_array( [$this->CI, $this->route->method], array_values($path_args) ); | |
| 131 | + call_user_func_array([$this->CI, $this->route->method], array_values($path_args)); | |
| 132 | 132 | } | 
| 133 | 133 | |
| 134 | 134 | |
| @@ -139,7 +139,7 @@ discard block | ||
| 139 | 139 | } | 
| 140 | 140 | else | 
| 141 | 141 |              { | 
| 142 | - if(ENVIRONMENT != 'production') | |
| 142 | + if (ENVIRONMENT != 'production') | |
| 143 | 143 |                  { | 
| 144 | 144 |                      show_error('The method '.$this->route->controller.'::'.$this->route->method.'() does not exists', 500, 'Method not found'); | 
| 145 | 145 | } | 
| @@ -129,17 +129,17 @@ discard block | ||
| 129 | 129 | */ | 
| 130 | 130 | public static function add($verb, $path, $attr, $hideOriginal = TRUE, $return = FALSE) | 
| 131 | 131 |      { | 
| 132 | - if(!is_array($attr)) | |
| 132 | + if (!is_array($attr)) | |
| 133 | 133 |          { | 
| 134 | -            show_error('You must specify the route attributes as an array',500,'Route error: bad attributes'); | |
| 134 | +            show_error('You must specify the route attributes as an array', 500, 'Route error: bad attributes'); | |
| 135 | 135 | } | 
| 136 | 136 | |
| 137 | - if(!isset($attr['uses'])) | |
| 137 | + if (!isset($attr['uses'])) | |
| 138 | 138 |          { | 
| 139 | 139 |              show_error('Route requires a \'controller@method\' to be pointed and it\'s not defined in the route attributes', 500, 'Route error: missing controller'); | 
| 140 | 140 | } | 
| 141 | 141 | |
| 142 | -        if(!preg_match('/^([a-zA-Z1-9-_]+)@([a-zA-Z1-9-_]+)$/', $attr['uses'], $parsedController) !== FALSE) | |
| 142 | +        if (!preg_match('/^([a-zA-Z1-9-_]+)@([a-zA-Z1-9-_]+)$/', $attr['uses'], $parsedController) !== FALSE) | |
| 143 | 143 |          { | 
| 144 | 144 |              show_error('Route controller must be in format controller@method', 500, 'Route error: bad controller format'); | 
| 145 | 145 | } | 
| @@ -147,34 +147,34 @@ discard block | ||
| 147 | 147 | $controller = $parsedController[1]; | 
| 148 | 148 | $method = $parsedController[2]; | 
| 149 | 149 | |
| 150 | - if(!is_string($path)) | |
| 150 | + if (!is_string($path)) | |
| 151 | 151 |              show_error('Route path must be a string ', 500, 'Route error: bad route path'); | 
| 152 | 152 | |
| 153 | - if(!is_string($verb)) | |
| 153 | + if (!is_string($verb)) | |
| 154 | 154 |              show_error('Route HTTP Verb must be a string', 500, 'Route error: bad verb type'); | 
| 155 | 155 | |
| 156 | 156 | $verb = strtoupper($verb); | 
| 157 | 157 | |
| 158 | - if(!in_array($verb, self::$http_verbs,TRUE)) | |
| 158 | + if (!in_array($verb, self::$http_verbs, TRUE)) | |
| 159 | 159 |          { | 
| 160 | 160 | $errorMsg = 'Verb "'.$verb.'" is not a valid HTTP Verb, allowed verbs:<ul>'; | 
| 161 | - foreach( self::$http_verbs as $validVerb ) | |
| 161 | + foreach (self::$http_verbs as $validVerb) | |
| 162 | 162 |              { | 
| 163 | 163 | $errorMsg .= '<li>'.$validVerb.'</li>'; | 
| 164 | 164 | } | 
| 165 | 165 | $errorMsg .= '</ul>'; | 
| 166 | - show_error($errorMsg,500,'Route error: unknow method'); | |
| 166 | + show_error($errorMsg, 500, 'Route error: unknow method'); | |
| 167 | 167 | } | 
| 168 | 168 | |
| 169 | 169 | $route['verb'] = $verb; | 
| 170 | 170 | |
| 171 | - $path = trim($path,'/'); | |
| 171 | + $path = trim($path, '/'); | |
| 172 | 172 | |
| 173 | 173 | $route['path'] = $path; | 
| 174 | 174 | $route['controller'] = $controller; | 
| 175 | 175 | $route['method'] = $method; | 
| 176 | 176 | |
| 177 | - if(isset($attr['as'])) | |
| 177 | + if (isset($attr['as'])) | |
| 178 | 178 |          { | 
| 179 | 179 | $route['name'] = $attr['as']; | 
| 180 | 180 | } | 
| @@ -188,10 +188,10 @@ discard block | ||
| 188 | 188 | $route['prefix'] = NULL; | 
| 189 | 189 |          $group_prefix = implode('/', self::$prefix); | 
| 190 | 190 | |
| 191 | - if($group_prefix) | |
| 191 | + if ($group_prefix) | |
| 192 | 192 | $route['prefix'] = $group_prefix.'/'; | 
| 193 | 193 | |
| 194 | - if(isset($attr['prefix'])) | |
| 194 | + if (isset($attr['prefix'])) | |
| 195 | 195 | $route['prefix'] .= $attr['prefix']; | 
| 196 | 196 | |
| 197 | 197 | // Setting up the namespace | 
| @@ -199,38 +199,38 @@ discard block | ||
| 199 | 199 | $route['namespace'] = NULL; | 
| 200 | 200 |          $group_namespace = implode('/', self::$namespace); | 
| 201 | 201 | |
| 202 | - if(!is_null($group_namespace)) | |
| 202 | + if (!is_null($group_namespace)) | |
| 203 | 203 | $route['namespace'] = $group_namespace.'/'; | 
| 204 | - if(isset($attr['namespace'])) | |
| 204 | + if (isset($attr['namespace'])) | |
| 205 | 205 | $route['namespace'] .= $attr['namespace']; | 
| 206 | 206 | |
| 207 | 207 | $route['prefix'] = trim($route['prefix'], '/'); | 
| 208 | - $route['namespace'] = trim($route['namespace'],'/'); | |
| 208 | + $route['namespace'] = trim($route['namespace'], '/'); | |
| 209 | 209 | |
| 210 | - if(empty($route['prefix'])) | |
| 210 | + if (empty($route['prefix'])) | |
| 211 | 211 | $route['prefix'] = NULL; | 
| 212 | 212 | |
| 213 | - if(empty($route['namespace'])) | |
| 213 | + if (empty($route['namespace'])) | |
| 214 | 214 | $route['namespace'] = NULL; | 
| 215 | 215 | |
| 216 | 216 | // Route middleware | 
| 217 | 217 | $route['middleware'] = []; | 
| 218 | 218 | $route['middleware'] = array_merge($route['middleware'], self::$middleware); | 
| 219 | 219 | |
| 220 | - if(isset($attr['middleware'])) | |
| 220 | + if (isset($attr['middleware'])) | |
| 221 | 221 |          { | 
| 222 | - if(is_array($attr['middleware'])) | |
| 222 | + if (is_array($attr['middleware'])) | |
| 223 | 223 |              { | 
| 224 | - foreach($attr['middleware'] as $middleware) | |
| 224 | + foreach ($attr['middleware'] as $middleware) | |
| 225 | 225 | $route['middleware'][] = $middleware; # Group | 
| 226 | 226 | } | 
| 227 | - elseif( is_string($attr['middleware'])) | |
| 227 | + elseif (is_string($attr['middleware'])) | |
| 228 | 228 |              { | 
| 229 | 229 | $route['middleware'][] = $attr['middleware']; # Group | 
| 230 | 230 | } | 
| 231 | 231 | else | 
| 232 | 232 |              { | 
| 233 | -                show_error('Route middleware must be a string or an array',500,'Route error: bad middleware format'); | |
| 233 | +                show_error('Route middleware must be a string or an array', 500, 'Route error: bad middleware format'); | |
| 234 | 234 | } | 
| 235 | 235 | } | 
| 236 | 236 | |
| @@ -243,27 +243,27 @@ discard block | ||
| 243 | 243 | |
| 244 | 244 | $groupHideOriginals = end(self::$hideOriginals); | 
| 245 | 245 | |
| 246 | - if($hideOriginal || $groupHideOriginals || ($compiledRoute->path != '' && $compiledRoute->path != '/' ) ) | |
| 246 | + if ($hideOriginal || $groupHideOriginals || ($compiledRoute->path != '' && $compiledRoute->path != '/')) | |
| 247 | 247 |          { | 
| 248 | 248 | $hiddenRoutePath = $controller.'/'.$method; | 
| 249 | 249 | $hiddenRouteNamespace = ''; | 
| 250 | 250 | |
| 251 | - if(!is_null($route['namespace'])) | |
| 251 | + if (!is_null($route['namespace'])) | |
| 252 | 252 |              { | 
| 253 | 253 | $hiddenRouteNamespace = $route['namespace'].'/'; | 
| 254 | 254 | } | 
| 255 | 255 | |
| 256 | 256 | $hiddenRoutePath = $hiddenRouteNamespace.$hiddenRoutePath; | 
| 257 | 257 | |
| 258 | - if($method == 'index') | |
| 258 | + if ($method == 'index') | |
| 259 | 259 |              { | 
| 260 | -                self::$hiddenRoutes[] = [ $hiddenRouteNamespace.$controller  => function(){ self::trigger404(); }]; | |
| 260 | +                self::$hiddenRoutes[] = [$hiddenRouteNamespace.$controller  => function() { self::trigger404(); }]; | |
| 261 | 261 | } | 
| 262 | 262 | |
| 263 | -            self::$hiddenRoutes[] = [$hiddenRoutePath => function(){ self::trigger404(); }]; | |
| 263 | +            self::$hiddenRoutes[] = [$hiddenRoutePath => function() { self::trigger404(); }]; | |
| 264 | 264 | } | 
| 265 | 265 | |
| 266 | - if(!$return) | |
| 266 | + if (!$return) | |
| 267 | 267 |          { | 
| 268 | 268 | self::$routes[] = (object) $route; | 
| 269 | 269 | } | 
| @@ -288,7 +288,7 @@ discard block | ||
| 288 | 288 | */ | 
| 289 | 289 | public static function get($url, $attr, $hideOriginal = TRUE) | 
| 290 | 290 |      { | 
| 291 | -        self::add('GET', $url,$attr, $hideOriginal); | |
| 291 | +        self::add('GET', $url, $attr, $hideOriginal); | |
| 292 | 292 | } | 
| 293 | 293 | |
| 294 | 294 | |
| @@ -306,7 +306,7 @@ discard block | ||
| 306 | 306 | */ | 
| 307 | 307 | public static function post($url, $attr, $hideOriginal = TRUE) | 
| 308 | 308 |      { | 
| 309 | -        self::add('POST', $url,$attr, $hideOriginal); | |
| 309 | +        self::add('POST', $url, $attr, $hideOriginal); | |
| 310 | 310 | } | 
| 311 | 311 | |
| 312 | 312 | |
| @@ -324,7 +324,7 @@ discard block | ||
| 324 | 324 | */ | 
| 325 | 325 | public static function put($url, $attr, $hideOriginal = TRUE) | 
| 326 | 326 |      { | 
| 327 | -        self::add('PUT', $url,$attr, $hideOriginal); | |
| 327 | +        self::add('PUT', $url, $attr, $hideOriginal); | |
| 328 | 328 | } | 
| 329 | 329 | |
| 330 | 330 | |
| @@ -342,7 +342,7 @@ discard block | ||
| 342 | 342 | */ | 
| 343 | 343 | public static function patch($url, $attr, $hideOriginal = TRUE) | 
| 344 | 344 |      { | 
| 345 | -        self::add('PATCH', $url,$attr, $hideOriginal); | |
| 345 | +        self::add('PATCH', $url, $attr, $hideOriginal); | |
| 346 | 346 | } | 
| 347 | 347 | |
| 348 | 348 | |
| @@ -360,7 +360,7 @@ discard block | ||
| 360 | 360 | */ | 
| 361 | 361 | public static function delete($url, $attr, $hideOriginal = TRUE) | 
| 362 | 362 |      { | 
| 363 | -        self::add('DELETE', $url,$attr, $hideOriginal); | |
| 363 | +        self::add('DELETE', $url, $attr, $hideOriginal); | |
| 364 | 364 | } | 
| 365 | 365 | |
| 366 | 366 | |
| @@ -378,7 +378,7 @@ discard block | ||
| 378 | 378 | */ | 
| 379 | 379 | public static function any($url, $attr, $hideOriginal = TRUE) | 
| 380 | 380 |      { | 
| 381 | - foreach(self::$http_verbs as $verb) | |
| 381 | + foreach (self::$http_verbs as $verb) | |
| 382 | 382 |          { | 
| 383 | 383 | $verb = strtolower($verb); | 
| 384 | 384 | self::add($verb, $url, $attr, $hideOriginal); | 
| @@ -401,10 +401,10 @@ discard block | ||
| 401 | 401 | */ | 
| 402 | 402 | public static function matches($verbs, $url, $attr, $hideOriginal = FALSE) | 
| 403 | 403 |      { | 
| 404 | - if(!is_array($verbs)) | |
| 404 | + if (!is_array($verbs)) | |
| 405 | 405 |              show_error('Route::matches() first argument must be an array of valid HTTP Verbs', 500, 'Route error: bad Route::matches() verb list'); | 
| 406 | 406 | |
| 407 | - foreach($verbs as $verb) | |
| 407 | + foreach ($verbs as $verb) | |
| 408 | 408 |          { | 
| 409 | 409 | self::add($verb, $url, $attr, $hideOriginal); | 
| 410 | 410 | } | 
| @@ -430,29 +430,29 @@ discard block | ||
| 430 | 430 | |
| 431 | 431 | $hideOriginal = FALSE; | 
| 432 | 432 | |
| 433 | - if(isset($attr['namespace'])) | |
| 433 | + if (isset($attr['namespace'])) | |
| 434 | 434 | $base_attr['namespace'] = $attr['namespace']; | 
| 435 | 435 | |
| 436 | - if(isset($attr['middleware'])) | |
| 436 | + if (isset($attr['middleware'])) | |
| 437 | 437 | $base_attr['middleware'] = $attr['middleware']; | 
| 438 | 438 | |
| 439 | - if(isset($attr['hideOriginal'])) | |
| 439 | + if (isset($attr['hideOriginal'])) | |
| 440 | 440 | $hideOriginal = (bool) $attr['hideOriginal']; | 
| 441 | 441 | |
| 442 | 442 | $base_attr['prefix'] = strtolower($name); | 
| 443 | 443 | |
| 444 | - if(isset($attr['prefix'])) | |
| 445 | - $base_attr['prefix'] = $attr['prefix']; | |
| 444 | + if (isset($attr['prefix'])) | |
| 445 | + $base_attr['prefix'] = $attr['prefix']; | |
| 446 | 446 | |
| 447 | 447 | $only = []; | 
| 448 | 448 | |
| 449 | 449 | $controller = strtolower($controller); | 
| 450 | 450 | |
| 451 | - if(isset($attr['only']) && (is_array($attr['only']) || is_string($attr['only']))) | |
| 451 | + if (isset($attr['only']) && (is_array($attr['only']) || is_string($attr['only']))) | |
| 452 | 452 |          { | 
| 453 | - if(is_array($attr['only'])) | |
| 453 | + if (is_array($attr['only'])) | |
| 454 | 454 |              { | 
| 455 | - $only = $attr['only']; | |
| 455 | + $only = $attr['only']; | |
| 456 | 456 | } | 
| 457 | 457 | else | 
| 458 | 458 |              { | 
| @@ -460,43 +460,43 @@ discard block | ||
| 460 | 460 | } | 
| 461 | 461 | } | 
| 462 | 462 | |
| 463 | -        if(empty($only) || in_array('index', $only)) | |
| 463 | +        if (empty($only) || in_array('index', $only)) | |
| 464 | 464 |          { | 
| 465 | - $route_attr = array_merge($base_attr, ['uses' => $controller.'@index', 'as' => $name.'.index']); | |
| 465 | + $route_attr = array_merge($base_attr, ['uses' => $controller.'@index', 'as' => $name.'.index']); | |
| 466 | 466 |              self::get('/', $route_attr, $hideOriginal); | 
| 467 | 467 | } | 
| 468 | 468 | |
| 469 | -        if(empty($only) || in_array('create', $only)) | |
| 469 | +        if (empty($only) || in_array('create', $only)) | |
| 470 | 470 |          { | 
| 471 | 471 | $route_attr = array_merge($base_attr, ['uses' => $controller.'@create', 'as' => $name.'.create']); | 
| 472 | 472 |              self::get('create', $route_attr, $hideOriginal); | 
| 473 | 473 | } | 
| 474 | 474 | |
| 475 | -        if(empty($only) || in_array('store', $only)) | |
| 475 | +        if (empty($only) || in_array('store', $only)) | |
| 476 | 476 |          { | 
| 477 | 477 | $route_attr = array_merge($base_attr, ['uses' => $controller.'@store', 'as' => $name.'.store']); | 
| 478 | 478 |              self::post('/', $route_attr, $hideOriginal); | 
| 479 | 479 | } | 
| 480 | 480 | |
| 481 | -        if(empty($only) || in_array('show', $only)) | |
| 481 | +        if (empty($only) || in_array('show', $only)) | |
| 482 | 482 |          { | 
| 483 | 483 | $route_attr = array_merge($base_attr, ['uses' => $controller.'@show', 'as' => $name.'.show']); | 
| 484 | 484 |              self::get('{slug}', $route_attr, $hideOriginal); | 
| 485 | 485 | } | 
| 486 | 486 | |
| 487 | -        if(empty($only) || in_array('edit', $only)) | |
| 487 | +        if (empty($only) || in_array('edit', $only)) | |
| 488 | 488 |          { | 
| 489 | 489 | $route_attr = array_merge($base_attr, ['uses' => $controller.'@edit', 'as' => $name.'.edit']); | 
| 490 | 490 |              self::get('{slug}/edit', $route_attr, $hideOriginal); | 
| 491 | 491 | } | 
| 492 | 492 | |
| 493 | -        if(empty($only) || in_array('update', $only)) | |
| 493 | +        if (empty($only) || in_array('update', $only)) | |
| 494 | 494 |          { | 
| 495 | 495 | $route_attr = array_merge($base_attr, ['uses' => $controller.'@update', 'as' => $name.'.update']); | 
| 496 | 496 |              self::matches(['PUT', 'PATCH'], '{slug}/update', $route_attr, $hideOriginal); | 
| 497 | 497 | } | 
| 498 | 498 | |
| 499 | -        if(empty($only) || in_array('destroy', $only)) | |
| 499 | +        if (empty($only) || in_array('destroy', $only)) | |
| 500 | 500 |          { | 
| 501 | 501 | $route_attr = array_merge($base_attr, ['uses' => $controller.'@destroy', 'as' => $name.'.destroy']); | 
| 502 | 502 |              self::delete('{slug}', $route_attr, $hideOriginal); | 
| @@ -519,33 +519,33 @@ discard block | ||
| 519 | 519 | $prefix = NULL; | 
| 520 | 520 | $namespace = NULL; | 
| 521 | 521 | |
| 522 | - if(!is_null($route->prefix)) | |
| 522 | + if (!is_null($route->prefix)) | |
| 523 | 523 |          { | 
| 524 | 524 | $prefix = $route->prefix; | 
| 525 | 525 | } | 
| 526 | 526 | |
| 527 | - if(!is_null($route->namespace)) | |
| 527 | + if (!is_null($route->namespace)) | |
| 528 | 528 |          { | 
| 529 | 529 | $namespace = $route->namespace; | 
| 530 | 530 | } | 
| 531 | 531 | |
| 532 | 532 | $path = $route->path; | 
| 533 | 533 | |
| 534 | - if(!is_null($prefix)) | |
| 534 | + if (!is_null($prefix)) | |
| 535 | 535 | $path = $prefix.'/'.$path; | 
| 536 | 536 | |
| 537 | 537 | $controller = $route->controller.'/'.$route->method; | 
| 538 | 538 | |
| 539 | - if(!is_null($namespace)) | |
| 539 | + if (!is_null($namespace)) | |
| 540 | 540 | $controller = $namespace.'/'.$controller; | 
| 541 | 541 | |
| 542 | - $path = trim($path,'/'); | |
| 543 | - $controller = trim($controller,'/'); | |
| 542 | + $path = trim($path, '/'); | |
| 543 | + $controller = trim($controller, '/'); | |
| 544 | 544 | $baseController = $controller; | 
| 545 | 545 | |
| 546 | 546 | $replaces = | 
| 547 | 547 | [ | 
| 548 | -                '{\((.*)\):[a-zA-Z0-9-_]*(\?}|})' => '($1)',   # Custom regular expression | |
| 548 | +                '{\((.*)\):[a-zA-Z0-9-_]*(\?}|})' => '($1)', # Custom regular expression | |
| 549 | 549 |                  '{num:[a-zA-Z0-9-_]*(\?}|})'      => '(:num)', # (:num) route | 
| 550 | 550 |                  '{any:[a-zA-Z0-9-_]*(\?}|})'      => '(:any)', # (:any) route | 
| 551 | 551 |                  '{[a-zA-Z0-9-_]*(\?}|})'          => '(:any)', # Everything else | 
| @@ -555,22 +555,22 @@ discard block | ||
| 555 | 555 | $basePath = ''; | 
| 556 | 556 | |
| 557 | 557 | |
| 558 | -        foreach(explode('/', $path) as $path_segment) | |
| 558 | +        foreach (explode('/', $path) as $path_segment) | |
| 559 | 559 |          { | 
| 560 | -            if(!preg_match('/^\{(.*)\}$/', $path_segment)) | |
| 560 | +            if (!preg_match('/^\{(.*)\}$/', $path_segment)) | |
| 561 | 561 |              { | 
| 562 | - $basePath .= $path_segment . '/' ; | |
| 562 | + $basePath .= $path_segment.'/'; | |
| 563 | 563 | } | 
| 564 | 564 | } | 
| 565 | 565 | |
| 566 | - $basePath = trim($basePath,'/'); | |
| 566 | + $basePath = trim($basePath, '/'); | |
| 567 | 567 | |
| 568 | - foreach($replaces as $regex => $replace) | |
| 568 | + foreach ($replaces as $regex => $replace) | |
| 569 | 569 |          { | 
| 570 | 570 | $matches = []; | 
| 571 | 571 | |
| 572 | 572 |              //if(preg_match_all('/'.$regex.'/', $path, $matches )) | 
| 573 | -            if(preg_match_all('/\{(.*)\}/', $path, $matches )) | |
| 573 | +            if (preg_match_all('/\{(.*)\}/', $path, $matches)) | |
| 574 | 574 |              { | 
| 575 | 575 | //$foundedArgs = $matches[0]; | 
| 576 | 576 |                  $foundedArgs = explode('/', $matches[0][0]); | 
| @@ -586,24 +586,24 @@ discard block | ||
| 586 | 586 | $args['required'] = []; | 
| 587 | 587 | $args['optional'] = []; | 
| 588 | 588 | |
| 589 | - foreach($foundedArgs as $arg) | |
| 589 | + foreach ($foundedArgs as $arg) | |
| 590 | 590 |          { | 
| 591 | - if(substr($arg,-2) == '?}') | |
| 591 | + if (substr($arg, -2) == '?}') | |
| 592 | 592 |              { | 
| 593 | 593 | $args['optional'][] = $arg; | 
| 594 | 594 | $argConstraint = TRUE; | 
| 595 | 595 | } | 
| 596 | 596 | else | 
| 597 | 597 |              { | 
| 598 | - if($argConstraint) | |
| 598 | + if ($argConstraint) | |
| 599 | 599 |                      show_error('Optional route path argument not valid at this position', 500, 'Route error'); | 
| 600 | 600 | $args['required'][] = $arg; | 
| 601 | 601 | } | 
| 602 | 602 | } | 
| 603 | 603 | |
| 604 | - if(count($foundedArgs) > 0) | |
| 604 | + if (count($foundedArgs) > 0) | |
| 605 | 605 |          { | 
| 606 | - for($i = 0; $i < count($foundedArgs); $i++) | |
| 606 | + for ($i = 0; $i < count($foundedArgs); $i++) | |
| 607 | 607 |              { | 
| 608 | 608 | $controller .= '/$'.($i + 1); | 
| 609 | 609 | } | 
| @@ -631,14 +631,14 @@ discard block | ||
| 631 | 631 |      { | 
| 632 | 632 | $routes = array(); | 
| 633 | 633 | |
| 634 | - foreach(self::$routes as $index => $route) | |
| 634 | + foreach (self::$routes as $index => $route) | |
| 635 | 635 |          { | 
| 636 | 636 | $compiled = self::compileRoute($route); | 
| 637 | 637 | |
| 638 | 638 | $backtrackingPath = ''; | 
| 639 | 639 | $backtrackingRoute = ''; | 
| 640 | 640 | |
| 641 | - if( count($compiled->args['optional']) > 0 ) | |
| 641 | + if (count($compiled->args['optional']) > 0) | |
| 642 | 642 |              { | 
| 643 | 643 |                  $e_path  = explode('/', $compiled->path); | 
| 644 | 644 |                  $e_route = explode('/', $compiled->route); | 
| @@ -646,54 +646,54 @@ discard block | ||
| 646 | 646 | $basePath = $compiled->basePath; | 
| 647 | 647 | $baseRoute = $compiled->baseRoute; | 
| 648 | 648 | |
| 649 | -                $a = count(explode('/',$basePath)); | |
| 649 | +                $a = count(explode('/', $basePath)); | |
| 650 | 650 | |
| 651 | - for($r = 0; $r < count($compiled->args['required']); $r++) | |
| 651 | + for ($r = 0; $r < count($compiled->args['required']); $r++) | |
| 652 | 652 |                  { | 
| 653 | - $basePath .= '/' . $e_path[ $a + $r ]; | |
| 654 | - $baseRoute .= '/' . '$' . ($r + 1); | |
| 653 | + $basePath .= '/'.$e_path[$a + $r]; | |
| 654 | + $baseRoute .= '/'.'$'.($r + 1); | |
| 655 | 655 | } | 
| 656 | 656 | |
| 657 | -                $a = count(explode('/',$basePath)); | |
| 657 | +                $a = count(explode('/', $basePath)); | |
| 658 | 658 | $b = ($r + 1); | 
| 659 | 659 | |
| 660 | 660 | $backtracking = []; | 
| 661 | 661 | |
| 662 | - for($o = 0; $o <= count($compiled->args['optional']); $o++) | |
| 662 | + for ($o = 0; $o <= count($compiled->args['optional']); $o++) | |
| 663 | 663 |                  { | 
| 664 | 664 | $backtrackingPath = $basePath; | 
| 665 | 665 | $backtrackingRoute = $baseRoute; | 
| 666 | 666 | |
| 667 | - for($c = 0; $c < $o ; $c++) | |
| 667 | + for ($c = 0; $c < $o; $c++) | |
| 668 | 668 |                      { | 
| 669 | - $backtrackingPath .= '/' . $e_path[$a + $c - 1]; | |
| 670 | - $backtrackingRoute .= '/' . '$' . ($b + $c); | |
| 669 | + $backtrackingPath .= '/'.$e_path[$a + $c - 1]; | |
| 670 | + $backtrackingRoute .= '/'.'$'.($b + $c); | |
| 671 | 671 | } | 
| 672 | 672 | |
| 673 | - $backtracking[$o] = [ 'path' => $backtrackingPath, 'route' => $backtrackingRoute ]; | |
| 673 | + $backtracking[$o] = ['path' => $backtrackingPath, 'route' => $backtrackingRoute]; | |
| 674 | 674 | } | 
| 675 | 675 | |
| 676 | - foreach($backtracking as $b_route) | |
| 676 | + foreach ($backtracking as $b_route) | |
| 677 | 677 |                  { | 
| 678 | 678 | $b_compiled = self::compileRoute($route); | 
| 679 | 679 | $b_args = array_merge($b_compiled->args['required'], $b_compiled->args['optional']); | 
| 680 | 680 | $b_route_path = $b_route['path']; | 
| 681 | 681 | |
| 682 | - foreach($b_args as $arg) | |
| 682 | + foreach ($b_args as $arg) | |
| 683 | 683 |                      { | 
| 684 | 684 |                          $b_route_path = preg_replace('/\((.*?)\)/', $arg, $b_route_path, 1); | 
| 685 | 685 | } | 
| 686 | 686 | |
| 687 | 687 | self::add($route->verb, $b_route_path, ['uses' => $route->controller.'@'.$route->method]); | 
| 688 | 688 | |
| 689 | - if( !isset($routes[$b_route['path']]) || $route->verb == 'GET' ) | |
| 689 | + if (!isset($routes[$b_route['path']]) || $route->verb == 'GET') | |
| 690 | 690 |                      { | 
| 691 | 691 | $routes[$b_route['path']] = $b_route['route']; | 
| 692 | 692 | } | 
| 693 | 693 | } | 
| 694 | 694 | } | 
| 695 | 695 | |
| 696 | - if( !isset($routes[$compiled->path]) || $route->verb == 'GET' ) | |
| 696 | + if (!isset($routes[$compiled->path]) || $route->verb == 'GET') | |
| 697 | 697 |              { | 
| 698 | 698 | $routes[$compiled->path] = $compiled->route; | 
| 699 | 699 | } | 
| @@ -701,16 +701,16 @@ discard block | ||
| 701 | 701 | self::$routes[$index] = (object) $route; | 
| 702 | 702 | } | 
| 703 | 703 | |
| 704 | - foreach(self::$hiddenRoutes as $route) | |
| 704 | + foreach (self::$hiddenRoutes as $route) | |
| 705 | 705 |          { | 
| 706 | 706 | $path = key($route); | 
| 707 | 707 | $_404 = $route[$path]; | 
| 708 | 708 | |
| 709 | - if(!isset($routes[$path])) | |
| 709 | + if (!isset($routes[$path])) | |
| 710 | 710 | $routes[$path] = $_404; | 
| 711 | 711 | } | 
| 712 | 712 | |
| 713 | - if(is_null(self::$defaultController)) | |
| 713 | + if (is_null(self::$defaultController)) | |
| 714 | 714 |              show_error('You must specify a home route: Route::home() as default controller!', 500, 'Route error: missing default controller'); | 
| 715 | 715 | |
| 716 | 716 | $defaultController = self::$defaultController->compiled; | 
| @@ -718,7 +718,7 @@ discard block | ||
| 718 | 718 | |
| 719 | 719 | $routes['default_controller'] = $defaultController; | 
| 720 | 720 | |
| 721 | - if(is_null(self::$_404page)) | |
| 721 | + if (is_null(self::$_404page)) | |
| 722 | 722 |          { | 
| 723 | 723 | $routes['404_override'] = ''; | 
| 724 | 724 | } | 
| @@ -746,20 +746,20 @@ discard block | ||
| 746 | 746 | */ | 
| 747 | 747 | public static function group($attr, $routes) | 
| 748 | 748 |      { | 
| 749 | - if(!is_array($attr)) | |
| 749 | + if (!is_array($attr)) | |
| 750 | 750 |              show_error('Group attribute must be a valid array'); | 
| 751 | 751 | |
| 752 | - if(!isset($attr['prefix'])) | |
| 752 | + if (!isset($attr['prefix'])) | |
| 753 | 753 |              show_error('You must specify an prefix!'); | 
| 754 | 754 | |
| 755 | 755 | self::$prefix[] = $attr['prefix']; | 
| 756 | 756 | |
| 757 | - if(isset($attr['namespace'])) | |
| 757 | + if (isset($attr['namespace'])) | |
| 758 | 758 |          { | 
| 759 | 759 | self::$namespace[] = $attr['namespace']; | 
| 760 | 760 | } | 
| 761 | 761 | |
| 762 | - if(isset($attr['hideOriginals']) && $attr['hideOriginals'] === TRUE) | |
| 762 | + if (isset($attr['hideOriginals']) && $attr['hideOriginals'] === TRUE) | |
| 763 | 763 |          { | 
| 764 | 764 | self::$hideOriginals[] = TRUE; | 
| 765 | 765 | } | 
| @@ -768,13 +768,13 @@ discard block | ||
| 768 | 768 | self::$hideOriginals[] = FALSE; | 
| 769 | 769 | } | 
| 770 | 770 | |
| 771 | - if(isset($attr['middleware'])) | |
| 771 | + if (isset($attr['middleware'])) | |
| 772 | 772 |          { | 
| 773 | - if(is_array($attr['middleware']) || is_string($attr['middleware'])) | |
| 773 | + if (is_array($attr['middleware']) || is_string($attr['middleware'])) | |
| 774 | 774 |              { | 
| 775 | - if(is_array($attr['middleware']) && !empty($attr['middleware'])) | |
| 775 | + if (is_array($attr['middleware']) && !empty($attr['middleware'])) | |
| 776 | 776 |                  { | 
| 777 | - foreach($attr['middleware'] as $middleware) | |
| 777 | + foreach ($attr['middleware'] as $middleware) | |
| 778 | 778 | self::$middleware[] = $middleware; | 
| 779 | 779 | } | 
| 780 | 780 | else | 
| @@ -818,16 +818,16 @@ discard block | ||
| 818 | 818 | 'as' => $as | 
| 819 | 819 | ]; | 
| 820 | 820 | |
| 821 | - if(!is_null($attr) && !is_array($attr)) | |
| 822 | -            show_error('Default controller attributes must be an array',500,'Route error: bad attribute type'); | |
| 821 | + if (!is_null($attr) && !is_array($attr)) | |
| 822 | +            show_error('Default controller attributes must be an array', 500, 'Route error: bad attribute type'); | |
| 823 | 823 | |
| 824 | - if(!is_null($attr)) | |
| 825 | - $routeAttr = array_merge($routeAttr,$attr); | |
| 824 | + if (!is_null($attr)) | |
| 825 | + $routeAttr = array_merge($routeAttr, $attr); | |
| 826 | 826 | |
| 827 | - if(isset($attr['prefix'])) | |
| 828 | -            show_error('Default controller may not have a prefix!',500,'Route error: prefix not allowed'); | |
| 827 | + if (isset($attr['prefix'])) | |
| 828 | +            show_error('Default controller may not have a prefix!', 500, 'Route error: prefix not allowed'); | |
| 829 | 829 | |
| 830 | -        self::$defaultController = self::$routes[] = self::add('GET', '/', ['uses' => $controller, 'as' => $as],TRUE, TRUE); | |
| 830 | +        self::$defaultController = self::$routes[] = self::add('GET', '/', ['uses' => $controller, 'as' => $as], TRUE, TRUE); | |
| 831 | 831 | } | 
| 832 | 832 | |
| 833 | 833 | |
| @@ -841,16 +841,16 @@ discard block | ||
| 841 | 841 | */ | 
| 842 | 842 | public static function getRoutes($verb = NULL) | 
| 843 | 843 |      { | 
| 844 | - if(is_null($verb)) | |
| 844 | + if (is_null($verb)) | |
| 845 | 845 |          { | 
| 846 | 846 | return self::$routes; | 
| 847 | 847 | } | 
| 848 | 848 | else | 
| 849 | 849 |          { | 
| 850 | 850 | $routes = []; | 
| 851 | - foreach(self::$routes as $route) | |
| 851 | + foreach (self::$routes as $route) | |
| 852 | 852 |              { | 
| 853 | - if($route->verb == $verb) | |
| 853 | + if ($route->verb == $verb) | |
| 854 | 854 | $routes[] = $route; | 
| 855 | 855 | } | 
| 856 | 856 | return $routes; | 
| @@ -890,45 +890,45 @@ discard block | ||
| 890 | 890 | $args = func_get_args(); | 
| 891 | 891 | unset($args[0]); | 
| 892 | 892 | |
| 893 | - foreach(self::$routes as $route) | |
| 893 | + foreach (self::$routes as $route) | |
| 894 | 894 |          { | 
| 895 | - if($route->name == $search) | |
| 895 | + if ($route->name == $search) | |
| 896 | 896 |              { | 
| 897 | 897 | $founded = $route; | 
| 898 | 898 | } | 
| 899 | 899 | } | 
| 900 | 900 | |
| 901 | - if(!is_null($founded)) | |
| 901 | + if (!is_null($founded)) | |
| 902 | 902 |          { | 
| 903 | 903 | $routeArgs = self::compileRoute($founded)->args; | 
| 904 | 904 | $routeArgCount = count($routeArgs['required']) + count($routeArgs['optional']); | 
| 905 | 905 | $routeReqArgCount = count($routeArgs['required']); | 
| 906 | 906 | |
| 907 | - if(count($args) < $routeReqArgCount) | |
| 907 | + if (count($args) < $routeReqArgCount) | |
| 908 | 908 |              { | 
| 909 | 909 | $missingArgs = $routeReqArgCount - count($args); | 
| 910 | 910 |                  throw new \Exception('Missing '.$missingArgs.' required argument'.($missingArgs != 1 ? 's' : '').' for route "'.$founded->name.'"'); | 
| 911 | 911 | } | 
| 912 | - if(count($args) > $routeArgCount) | |
| 912 | + if (count($args) > $routeArgCount) | |
| 913 | 913 |              { | 
| 914 | 914 |                  throw new \Exception('The route "'.$founded->name.'" expects maximum '.$routeArgCount.' argument'.($routeArgCount != 1 ? 's' : '').', '.count($args).' provided'); | 
| 915 | 915 | } | 
| 916 | 916 | |
| 917 | 917 | $path = self::compileRoute($founded)->path; | 
| 918 | 918 | |
| 919 | - foreach($args as $replacement) | |
| 919 | + foreach ($args as $replacement) | |
| 920 | 920 |              { | 
| 921 | 921 |                  $path = preg_replace('/\((.*?)\)/', $replacement, $path, 1); | 
| 922 | 922 | } | 
| 923 | 923 | |
| 924 | - $argsLeft = $routeArgCount - count($args); | |
| 924 | + $argsLeft = $routeArgCount - count($args); | |
| 925 | 925 | |
| 926 | - for($i = $argsLeft; $i >= 0; $i--) | |
| 926 | + for ($i = $argsLeft; $i >= 0; $i--) | |
| 927 | 927 |              { | 
| 928 | 928 |                  $path = preg_replace('/\((.*?)\)/', '', $path, 1); | 
| 929 | 929 | } | 
| 930 | 930 | |
| 931 | - return base_url(trim($path,'/')); | |
| 931 | + return base_url(trim($path, '/')); | |
| 932 | 932 | } | 
| 933 | 933 | |
| 934 | 934 |          throw new \Exception('The route "'.$search.'" is not defined'); | 
| @@ -947,17 +947,17 @@ discard block | ||
| 947 | 947 | */ | 
| 948 | 948 | public static function getRouteByPath($path, $requestMethod = NULL) | 
| 949 | 949 |      { | 
| 950 | - if(is_null($requestMethod)) | |
| 950 | + if (is_null($requestMethod)) | |
| 951 | 951 | $requestMethod = $_SERVER['REQUEST_METHOD']; | 
| 952 | 952 | |
| 953 | 953 | $routes = self::getRoutes($requestMethod); | 
| 954 | 954 | |
| 955 | - if(empty($routes)) | |
| 955 | + if (empty($routes)) | |
| 956 | 956 | return FALSE; | 
| 957 | 957 | |
| 958 | 958 | $path = trim($path); | 
| 959 | 959 | |
| 960 | - if($path == '') | |
| 960 | + if ($path == '') | |
| 961 | 961 | return self::$defaultController; | 
| 962 | 962 | |
| 963 | 963 | $wildcards = | 
| @@ -974,17 +974,17 @@ discard block | ||
| 974 | 974 | '(.*)' | 
| 975 | 975 | ]; | 
| 976 | 976 | |
| 977 | - foreach( ['exact' , 'regex'] as $mode) | |
| 977 | + foreach (['exact', 'regex'] as $mode) | |
| 978 | 978 |          { | 
| 979 | - foreach( [ $path, $path.'/index' ] as $findPath ) | |
| 979 | + foreach ([$path, $path.'/index'] as $findPath) | |
| 980 | 980 |              { | 
| 981 | - foreach($routes as $route) | |
| 981 | + foreach ($routes as $route) | |
| 982 | 982 |                  { | 
| 983 | 983 | $compiledPath = key($route->compiled); | 
| 984 | 984 | |
| 985 | - if($mode == 'exact') | |
| 985 | + if ($mode == 'exact') | |
| 986 | 986 |                      { | 
| 987 | - if($findPath == $compiledPath) | |
| 987 | + if ($findPath == $compiledPath) | |
| 988 | 988 | return $route; | 
| 989 | 989 | } | 
| 990 | 990 | else | 
| @@ -992,30 +992,30 @@ discard block | ||
| 992 | 992 |                          $e_findPath     = explode('/', $findPath); | 
| 993 | 993 |                          $e_compiledPath = explode('/', $compiledPath); | 
| 994 | 994 | |
| 995 | - if( count($e_findPath) == count($e_compiledPath)) | |
| 995 | + if (count($e_findPath) == count($e_compiledPath)) | |
| 996 | 996 |                          { | 
| 997 | 997 | //var_dump($findPath, $compiledPath); | 
| 998 | 998 | |
| 999 | 999 | $valid = TRUE; | 
| 1000 | 1000 | $seachUntil = NULL; | 
| 1001 | 1001 | |
| 1002 | - for($i = 0; $i < count($e_findPath); $i++) | |
| 1002 | + for ($i = 0; $i < count($e_findPath); $i++) | |
| 1003 | 1003 |                              { | 
| 1004 | 1004 | $reg = preg_replace($wildcards, $replaces, $e_compiledPath[$i]); | 
| 1005 | 1005 | |
| 1006 | 1006 |                                  $valid = (bool) preg_match('#^'.$reg.'$#', $e_findPath[$i]); | 
| 1007 | 1007 | |
| 1008 | - if($valid && is_null($seachUntil)) | |
| 1008 | + if ($valid && is_null($seachUntil)) | |
| 1009 | 1009 | $seachUntil = $i; | 
| 1010 | 1010 | } | 
| 1011 | 1011 | |
| 1012 | - if($valid) | |
| 1012 | + if ($valid) | |
| 1013 | 1013 |                              { | 
| 1014 | - for($i = 0; $i < $seachUntil; $i++) | |
| 1014 | + for ($i = 0; $i < $seachUntil; $i++) | |
| 1015 | 1015 | $valid = $e_findPath[$i] == $e_compiledPath[$i]; | 
| 1016 | 1016 | } | 
| 1017 | 1017 | |
| 1018 | - if($valid) | |
| 1018 | + if ($valid) | |
| 1019 | 1019 | return $route; | 
| 1020 | 1020 | } | 
| 1021 | 1021 | } | 
| @@ -1048,12 +1048,12 @@ discard block | ||
| 1048 | 1048 | $args = []; | 
| 1049 | 1049 | $n_args = 1; | 
| 1050 | 1050 | |
| 1051 | - for($s = 0; $s < count($r_seg); $s++) | |
| 1051 | + for ($s = 0; $s < count($r_seg); $s++) | |
| 1052 | 1052 |          { | 
| 1053 | - if(!isset($p_seg[$s])) | |
| 1053 | + if (!isset($p_seg[$s])) | |
| 1054 | 1054 | continue; | 
| 1055 | 1055 | |
| 1056 | - if($r_seg[$s] != $p_seg[$s]) | |
| 1056 | + if ($r_seg[$s] != $p_seg[$s]) | |
| 1057 | 1057 |              { | 
| 1058 | 1058 | $args['$'.$n_args] = $p_seg[$s]; | 
| 1059 | 1059 | $n_args++; | 
| @@ -1141,9 +1141,9 @@ discard block | ||
| 1141 | 1141 | */ | 
| 1142 | 1142 | public static function trigger404() | 
| 1143 | 1143 |      { | 
| 1144 | - if( !is_null(self::$_404page) ) | |
| 1144 | + if (!is_null(self::$_404page)) | |
| 1145 | 1145 |          { | 
| 1146 | -            header( 'Location: ' . config_item('base_url') . self::$_404page->path ); | |
| 1146 | +            header('Location: '.config_item('base_url').self::$_404page->path); | |
| 1147 | 1147 | die; | 
| 1148 | 1148 | } | 
| 1149 | 1149 | |
| @@ -50,7 +50,7 @@ discard block | ||
| 50 | 50 | */ | 
| 51 | 51 | public function __construct() | 
| 52 | 52 |      { | 
| 53 | - $this->CI =& self::$instance; | |
| 53 | + $this->CI = & self::$instance; | |
| 54 | 54 | } | 
| 55 | 55 | |
| 56 | 56 | /** | 
| @@ -63,7 +63,7 @@ discard block | ||
| 63 | 63 | */ | 
| 64 | 64 | public static function init() | 
| 65 | 65 |      { | 
| 66 | - self::$instance =& get_instance(); | |
| 66 | + self::$instance = & get_instance(); | |
| 67 | 67 | self::$uri_string = self::$instance->router->uri->uri_string(); | 
| 68 | 68 | |
| 69 | 69 | // Execute user defined middleware: | 
| @@ -92,16 +92,16 @@ discard block | ||
| 92 | 92 | $_run = array(); | 
| 93 | 93 | |
| 94 | 94 | // Current route middleware | 
| 95 | - if($currentRoute !== FALSE) | |
| 95 | + if ($currentRoute !== FALSE) | |
| 96 | 96 |          { | 
| 97 | - foreach($currentRoute->middleware as $middleware) | |
| 97 | + foreach ($currentRoute->middleware as $middleware) | |
| 98 | 98 |              { | 
| 99 | - if(!in_array($middleware,$_run)) | |
| 99 | + if (!in_array($middleware, $_run)) | |
| 100 | 100 | $_run[] = $middleware; | 
| 101 | 101 | } | 
| 102 | 102 | } | 
| 103 | 103 | |
| 104 | - foreach($_run as $middleware) | |
| 104 | + foreach ($_run as $middleware) | |
| 105 | 105 |          { | 
| 106 | 106 | self::runMiddleware($middleware); | 
| 107 | 107 | } | 
| @@ -125,30 +125,30 @@ discard block | ||
| 125 | 125 | |
| 126 | 126 | $middlewareName = ucfirst($middlewareName).'_middleware'; | 
| 127 | 127 | |
| 128 | - if(!file_exists($middlewareDir)) | |
| 128 | + if (!file_exists($middlewareDir)) | |
| 129 | 129 |              show_error('Unable to find (or read) the middleware folder: "'.$middlewareDir.'"'); | 
| 130 | 130 | |
| 131 | - $runMiddleware = $middlewareDir.$middlewareName.'.php'; | |
| 131 | + $runMiddleware = $middlewareDir.$middlewareName.'.php'; | |
| 132 | 132 | |
| 133 | - if(!file_exists($runMiddleware)) | |
| 133 | + if (!file_exists($runMiddleware)) | |
| 134 | 134 |              show_error('Unable to find (or read) the middleware "'.$runMiddleware.'"'); | 
| 135 | 135 | |
| 136 | 136 | require $runMiddleware; | 
| 137 | 137 | |
| 138 | - if(!class_exists($middlewareName)) | |
| 138 | + if (!class_exists($middlewareName)) | |
| 139 | 139 |              show_error('Class "'.$middlewareName.'" not found'); | 
| 140 | 140 | |
| 141 | 141 | $middleware = new $middlewareName(); | 
| 142 | 142 | |
| 143 | 143 | // Call the current controller __beforeMiddleware() method, if exists: | 
| 144 | - if(method_exists(self::$instance, '_beforeMiddleware')) | |
| 144 | + if (method_exists(self::$instance, '_beforeMiddleware')) | |
| 145 | 145 | self::$instance->_beforeMiddleware(); | 
| 146 | 146 | |
| 147 | 147 | // Run the middleware | 
| 148 | 148 | $middleware->run(); | 
| 149 | 149 | |
| 150 | 150 | // Call the current controller _afterMiddleware() method, if exists: | 
| 151 | - if(method_exists(self::$instance, '_afterMiddleware')) | |
| 151 | + if (method_exists(self::$instance, '_afterMiddleware')) | |
| 152 | 152 | self::$instance->_afterMiddleware(); | 
| 153 | 153 | |
| 154 | 154 | } |