本文整理汇总了PHP中DefaultController::handle方法的典型用法代码示例。如果您正苦于以下问题:PHP DefaultController::handle方法的具体用法?PHP DefaultController::handle怎么用?PHP DefaultController::handle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DefaultController
的用法示例。
在下文中一共展示了DefaultController::handle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
public function handle($params)
{
if ($this->_cName == null) {
// above parseRoute() failed (controller not found) => run Default Controller (if specified)
global $app_i;
$def = trim($app_i['default_controller']);
if ($def != '' && file_exists(BASE . $def)) {
require_once BASE . $def;
$ctr = new DefaultController();
$ctr->handle(null);
$this->log->debug('Invalid URI. DefaultController called.');
return;
}
}
// URI parsed OK!
$fullpath = '/app/' . $this->_cPath . '/' . $this->_cName . '.php';
$this->log->debug('handle() route: ' . $fullpath);
$fullpath = BASE . $fullpath;
if (file_exists($fullpath)) {
// load parsed Controller
require_once $fullpath;
$ctr = new $this->_cName();
$ctr->handle($this->_cParams);
} else {
die('MainController: Error: Controller not found!');
}
$this->log->debug('handle() ended');
}
示例2: Exception
break;
default:
throw new Exception('API version must be specified', 404);
break;
}
if (isset($parameters['oauth_version']) && $request->url_elements[2] != 'oauth') {
$oauth_model = new OAuthModel();
$oauth_model->in_flight = true;
$oauth_model->setUpOAuthAndDb($ji_db);
$request->user_id = $oauth_model->user_id;
}
// Route: call the handle() method of the class with the first URL element
if (isset($request->url_elements[2])) {
$class = ucfirst($request->url_elements[2]) . 'Controller';
if (class_exists($class)) {
$handler = new $class();
$return_data = $handler->handle($request, $ji_db);
// the DB is set by the database config
} else {
throw new Exception('Unknown controller ' . $request->url_elements[2], 400);
}
} else {
throw new Exception('Request not understood', 404);
}
} else {
$defaultController = new DefaultController();
$return_data = $defaultController->handle($request, $ji_db);
}
// Handle output
// TODO sort out headers, caching, etc
$request->view->render($return_data);