|
|
|
|
@ -10,6 +10,8 @@ declare(strict_types=1); |
|
|
|
|
|
|
|
|
|
namespace CodeHydrater; |
|
|
|
|
|
|
|
|
|
use \CodeHydrater\http\request as Request; |
|
|
|
|
use \CodeHydrater\http\response as Response; |
|
|
|
|
use Exception; |
|
|
|
|
|
|
|
|
|
class app { |
|
|
|
|
@ -155,7 +157,7 @@ class app { |
|
|
|
|
* @param string $method |
|
|
|
|
* @retval type |
|
|
|
|
*/ |
|
|
|
|
private function action(string $file, string $class, string $method, $params) { |
|
|
|
|
private function action(Request $request, Response $response, string $file, string $class, string $method, $params) { |
|
|
|
|
$safer_file = bootstrap\requires::safer_file_exists($file); |
|
|
|
|
if (! $safer_file) { |
|
|
|
|
$this->local404(); |
|
|
|
|
@ -168,7 +170,7 @@ class app { |
|
|
|
|
$test = $this->get_ctrl_dir(); |
|
|
|
|
|
|
|
|
|
$call_class = "\\Project\\" . $test . 'controllers\\' . $class; |
|
|
|
|
$controller = new $call_class(); |
|
|
|
|
$controller = new $call_class($request, $response); |
|
|
|
|
|
|
|
|
|
if ($method === "error" && str_contains($class, "app") && |
|
|
|
|
method_exists($controller, $method) === false |
|
|
|
|
@ -203,8 +205,8 @@ class app { |
|
|
|
|
/** |
|
|
|
|
* Does load controller by calling action |
|
|
|
|
*/ |
|
|
|
|
public function load_controller() { |
|
|
|
|
return $this->action($this->file, $this->class, $this->method, $this->params); |
|
|
|
|
public function load_controller(Request $request, Response $response) { |
|
|
|
|
return $this->action($request, $response, $this->file, $this->class, $this->method, $this->params); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} // end of app |
|
|
|
|
|