Fixed mixed indents
This commit is contained in:
parent
7f6d6eb9c6
commit
3a8218687f
54
Route.php
54
Route.php
|
@ -2,45 +2,45 @@
|
|||
|
||||
class Route{
|
||||
|
||||
private static $routes = Array();
|
||||
private static $pathNotFound = null;
|
||||
private static $routes = Array();
|
||||
private static $pathNotFound = null;
|
||||
private static $methodNotAllowed = null;
|
||||
|
||||
public static function add($expression, $function, $method = 'get'){
|
||||
array_push(self::$routes,Array(
|
||||
'expression' => $expression,
|
||||
'function' => $function,
|
||||
public static function add($expression, $function, $method = 'get'){
|
||||
array_push(self::$routes,Array(
|
||||
'expression' => $expression,
|
||||
'function' => $function,
|
||||
'method' => $method
|
||||
));
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
public static function pathNotFound($function){
|
||||
self::$pathNotFound = $function;
|
||||
}
|
||||
public static function pathNotFound($function){
|
||||
self::$pathNotFound = $function;
|
||||
}
|
||||
|
||||
public static function methodNotAllowed($function){
|
||||
self::$methodNotAllowed = $function;
|
||||
}
|
||||
self::$methodNotAllowed = $function;
|
||||
}
|
||||
|
||||
public static function run($basepath = '/'){
|
||||
public static function run($basepath = '/'){
|
||||
|
||||
// Parse current url
|
||||
$parsed_url = parse_url($_SERVER['REQUEST_URI']);//Parse Uri
|
||||
$parsed_url = parse_url($_SERVER['REQUEST_URI']);//Parse Uri
|
||||
|
||||
if(isset($parsed_url['path'])){
|
||||
$path = $parsed_url['path'];
|
||||
}else{
|
||||
$path = '/';
|
||||
}
|
||||
if(isset($parsed_url['path'])){
|
||||
$path = $parsed_url['path'];
|
||||
}else{
|
||||
$path = '/';
|
||||
}
|
||||
|
||||
// Get current request method
|
||||
$method = $_SERVER['REQUEST_METHOD'];
|
||||
|
||||
$path_match_found = false;
|
||||
$path_match_found = false;
|
||||
|
||||
$route_match_found = false;
|
||||
|
||||
foreach(self::$routes as $route){
|
||||
foreach(self::$routes as $route){
|
||||
|
||||
// If the method matches check the path
|
||||
|
||||
|
@ -78,11 +78,11 @@ class Route{
|
|||
// Do not check other routes
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// No matching route was found
|
||||
if(!$route_match_found){
|
||||
if(!$route_match_found){
|
||||
|
||||
// But a matching path exists
|
||||
if($path_match_found){
|
||||
|
@ -97,8 +97,8 @@ class Route{
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user