From d7f3313ff4514e38c9f53439cd1a1287e56e45f7 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Sun, 11 Nov 2018 17:19:26 +0100 Subject: reboot folder --- app/class/routes.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/class/routes.php (limited to 'app/class/routes.php') diff --git a/app/class/routes.php b/app/class/routes.php new file mode 100644 index 0000000..6f37b93 --- /dev/null +++ b/app/class/routes.php @@ -0,0 +1,34 @@ +addRoutes([ + ['GET|POST', '/', 'Backrouter#run', 'backrouter'], + ['GET', '/[a:art]/', 'Controllerart#read', 'artread/'], + ['GET', '/[a:art]', 'Controllerart#read', 'artread'], + ['GET', '/[a:art]/edit', 'Controllerart#edit', 'artedit'], + ['GET', '/[a:art]/edit/', 'Controllerart#edit', 'artedit/'], + ]); + + $match = $router->match(); + if ($match) { + $callableParts = explode('#', $match['target']); + $controllerName = $callableParts[0]; + $methodName = $callableParts[1]; + + $controller = new $controllerName(); + + call_user_func_array(array($controller, $methodName), $match['params']); + } + //404 + else { + header($_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found'); + } + } +} \ No newline at end of file -- cgit v1.2.3