本文整理汇总了PHP中Req::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Req::init方法的具体用法?PHP Req::init怎么用?PHP Req::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Req
的用法示例。
在下文中一共展示了Req::init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadController
/**
* Load Controller
*/
private function loadController()
{
$param = explode('/', $this->param());
// Set Deafult Controller
if ('' === $param[0]) {
$param[0] = $this->set['controller/default'];
}
$controller_param_temp = $param;
$controller_name_temp = ucfirst($this->set['name']) . '\\Controller';
$controller_path_temp = $this->set['controller'];
$controller_is_found = false;
$controller_param = $controller_param_temp;
$controller_name = $controller_name_temp;
$controller_path = $controller_path_temp;
// Search Controller
while ($param) {
$file_name = ucfirst($param[0]);
if (file_exists("{$controller_path_temp}/{$file_name}Controller.php")) {
array_shift($param);
$controller_param_temp = $param;
$controller_name_temp = "{$controller_name_temp}\\{$file_name}";
$controller_path_temp = "{$controller_path_temp}/{$file_name}";
$controller_is_found = true;
$controller_param = $controller_param_temp;
$controller_name = $controller_name_temp;
$controller_path = $controller_path_temp;
} elseif (file_exists("{$controller_path_temp}/{$file_name}")) {
array_shift($param);
$controller_param_temp = $param;
$controller_name_temp = "{$controller_name_temp}\\{$file_name}";
$controller_path_temp = "{$controller_path_temp}/{$file_name}";
} else {
break;
}
}
// Response HTTP Status Code 404
if (!$controller_is_found) {
http_response_code(404);
return false;
}
// Require Controller
require $controller_path . 'Controller.php';
// New Controller Instance
$controller_name .= 'Controller';
$controller = new $controller_name();
if (method_exists($controller, $this->method() . 'Action')) {
// Initialize Request Module
Req::init(['method' => $this->method(), 'param' => $controller_param]);
// Initialize Response Module
Res::init(['path' => $this->set['view']]);
// Call Function: up -> xxxAction -> down
if (false !== $controller->up()) {
$method = $this->method() . 'Action';
$controller->{$method}();
}
$controller->down();
return true;
}
http_response_code(501);
return false;
}