本文整理匯總了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);