-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRouting.php
More file actions
37 lines (27 loc) · 962 Bytes
/
Copy pathRouting.php
File metadata and controls
37 lines (27 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
require_once 'src/controllers/DefaultController.php';
require_once 'src/controllers/SecurityController.php';
require_once 'src/controllers/HomepageController.php';
require_once 'src/controllers/BillController.php';
require_once 'src/controllers/BillController.php';
require_once 'src/controllers/RoomController.php';
class Routing {
public static $routes;
public static function get($url, $viewController){
self::$routes[$url] = $viewController;
}
public static function post($url, $viewController){
self::$routes[$url] = $viewController;
}
public static function run($url){
$action = explode("/",$url)[0];
if(!array_key_exists($action,self::$routes)){
echo "action: [".$action."]";
die("Wrong url!");
}
$controller = self::$routes[$action];
$object = new $controller;
$action = $action ?: 'index';
$object->$action();
}
}