本文整理汇总了PHP中Routes::addRoute方法的典型用法代码示例。如果您正苦于以下问题:PHP Routes::addRoute方法的具体用法?PHP Routes::addRoute怎么用?PHP Routes::addRoute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Routes
的用法示例。
在下文中一共展示了Routes::addRoute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRoutes
public static function getRoutes()
{
return self::$routes;
}
public static function getPath($controller, $action, $absolute = true)
{
if ($absolute) {
return $_SERVER['REMOTE_HOST'] . self::$routes_inverse[$controller . "_" . $action];
} else {
return self::$routes_inverse[$controller . "_" . $action];
}
}
public function addRoute($path, $httpMethod, $controller, $action, $format = "html")
{
self::$routes[$path . "__" . $httpMethod . "__" . $format] = [$controller, $action];
self::$routes_inverse[$controller . "_" . $action] = $path;
}
}
Routes::addRoute("/", "GET", "Site", "index");
Routes::addRoute("/login", "GET", "Site", "login");
Routes::addRoute("/register", "GET", "Site", "register");
Routes::addRoute("/logout", "GET", "User", "logout");
Routes::addRoute("/cart/buy", "GET", "Transaction", "buy");
Routes::addRoute("/cart/checkout", "POST", "Transaction", "checkout");
Routes::addRoute("/cart/history", "GET", "Transaction", "history");
Routes::addRoute("/user/register", "POST", "User", "register");
Routes::addRoute("/postlogin", "POST", "Site", "postLogin");
Routes::addRoute("/postregister", "POST", "Site", "postRegister");
Routes::addRoute("/user/edit", "GET", "User", "edit");
Routes::addRoute("/user/save", "POST", "User", "save");