/** * Mapping the routes to their controllers * @return void */ public static function map() { \Service::call("\\Page"); if (isset(\Kernel::$request->query['p'])) { $path = substr(\Kernel::$request->query['p'], 1); if (substr($path, strlen($path) - 1, strlen($path)) == '/') { $path = substr($path, 0, strlen($path) - 1); } } else { $path = ""; } $routes = (object) self::$routes; if (isset($routes->{\Kernel::$request->server['REQUEST_METHOD']})) { $found = false; foreach ($routes->{\Kernel::$request->server['REQUEST_METHOD']} as $key => $value) { if (preg_match($key, $path, $params)) { foreach ($params as $key => $v) { if (is_numeric($key)) { unset($params[$key]); } } self::$usedRoute = $value; $value->trigger($params); $found = true; break; } else { continue; } } if (!$found) { self::notFoundAction($path); } } else { self::notFoundAction($path); } }