/** * 解析命令 * * @param string $controller 控制器 * @param string $action 方法 * @return URLComponent */ public static function parseController($controller, $action) { $request = Request::getInstance(); $controller = strtolower($controller); $controller = ctype_alpha($controller) ? $controller : 'index'; $controller = ucfirst($controller); $action = str_replace(array('_', '-'), ' ', $action); $action = ucwords($action); $action = strtolower($action); $action = ucfirst($action); $action = str_replace(' ', '', $action); $action = ctype_alpha($action) ? $action : 'Index'; if (!$request->isPost()) { $action = 'get' . $action; } elseif ($request->isPost()) { $action = 'post' . $action; } $Url = new URLComponent(); $Url->setController($controller)->setAction($action); return $Url; }