|
|
@ -176,33 +176,25 @@ class Router { |
|
|
|
$controller = '\App\Controllers\\' . $controller; |
|
|
|
$controller = '\App\Controllers\\' . $controller; |
|
|
|
$controller = new $controller(self::$router); |
|
|
|
$controller = new $controller(self::$router); |
|
|
|
|
|
|
|
|
|
|
|
$stillValid = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If method does not exist in object |
|
|
|
// If method does not exist in object |
|
|
|
if (!method_exists($controller, $action)) { |
|
|
|
if (!method_exists($controller, $action)) { |
|
|
|
$stillValid = false; |
|
|
|
return $controller->throw404(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// If no valid permissions |
|
|
|
// If no valid permissions |
|
|
|
if ($controller->getAdminSection() && |
|
|
|
if ($controller->getAdminSection() && |
|
|
|
$controller->getLoggedIn() == false) { |
|
|
|
$controller->getLoggedIn() == false) { |
|
|
|
$stillValid = false; |
|
|
|
return $controller->throw404(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Call Controller action |
|
|
|
|
|
|
|
if ($stillValid) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Loop through params |
|
|
|
// Loop through params |
|
|
|
$params = []; |
|
|
|
$params = []; |
|
|
|
foreach ($param as $name) { |
|
|
|
foreach ($param as $name) { |
|
|
|
$params[] = $request->param($name); |
|
|
|
$params[] = $request->param($name); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Call Controller action |
|
|
|
return $controller->{$action}(...$params); |
|
|
|
return $controller->{$action}(...$params); |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
$controller->throw404(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -227,21 +219,18 @@ class Router { |
|
|
|
$route[2] .= 'Action'; |
|
|
|
$route[2] .= 'Action'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$stillValid = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If method does not exist in object |
|
|
|
// If method does not exist in object |
|
|
|
if (!method_exists($controller, $route[2])) { |
|
|
|
if (!method_exists($controller, $route[2])) { |
|
|
|
$stillValid = false; |
|
|
|
return $controller->throw404(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// If no valid permissions |
|
|
|
// If no valid permissions |
|
|
|
if ($controller->getAdminSection() && |
|
|
|
if ($controller->getAdminSection() && |
|
|
|
$controller->getLoggedIn() == false) { |
|
|
|
$controller->getLoggedIn() == false) { |
|
|
|
$stillValid = false; |
|
|
|
return $controller->throw404(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Call Controller action |
|
|
|
// Call Controller action |
|
|
|
if ($stillValid) { |
|
|
|
|
|
|
|
if (is_array($route[3])) { |
|
|
|
if (is_array($route[3])) { |
|
|
|
return $controller->{$route[2]}( |
|
|
|
return $controller->{$route[2]}( |
|
|
|
$route[3][0] ?? '', |
|
|
|
$route[3][0] ?? '', |
|
|
@ -255,10 +244,6 @@ class Router { |
|
|
|
else { |
|
|
|
else { |
|
|
|
return $controller->{$route[2]}(); |
|
|
|
return $controller->{$route[2]}(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
$controller->throw404(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|