本文整理汇总了PHP中HttpResponse::sendError方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpResponse::sendError方法的具体用法?PHP HttpResponse::sendError怎么用?PHP HttpResponse::sendError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpResponse
的用法示例。
在下文中一共展示了HttpResponse::sendError方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: route
/**
* route
*
* @access public
* @return void
*/
public function route()
{
global $app;
$controllerName = $this->_command->getControllerName();
if (!$this->routeExists($controllerName)) {
$controllerName = 'error';
}
include 'controllers/' . $controllerName . '.php';
// Only log analytics data for non-login pages here
if (strcasecmp($controllerName, 'login') !== 0) {
if ($app->getConfiguration()->logAnalytics() == true) {
$analyticsData = array();
$analyticsData['time'] = time();
$analyticsData['session'] = session_id();
$analyticsData['page'] = $controllerName;
$GLOBALS['routeLogger']->info(json_encode($analyticsData));
}
}
$controllerClass = $controllerName . 'Controller';
$controller = new $controllerClass($this->_command);
//$controller->addPreProcessor();
try {
$params = $controller->getParams();
$request = new HttpRequest($params);
$request->parse();
$controller->execute($request);
} catch (MissingParamsException $mpe) {
$response = new HttpResponse();
$response->addHeader('HTTP/1.1 400 Bad Request');
$response->send();
} catch (ServiceException $sxe) {
$response = new HttpResponse();
$response->sendError($sxe->getMessage());
} catch (ClientException $cxe) {
$response = new HttpResponse();
$response->sendError($cxe->getMessage(), $cxe->getCode());
}
}