本文整理汇总了PHP中Illuminate\Support\Facades\Response::error方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::error方法的具体用法?PHP Response::error怎么用?PHP Response::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Response
的用法示例。
在下文中一共展示了Response::error方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
|
| Check that the current user is logged in and has a the permission corresponding to the config menu file
|
*/
Route::filter('can_see', function () {
$route_helper = new FileRouteHelper();
if (!$route_helper->hasPermForRoute(Route::currentRouteName())) {
App::abort('401');
}
});
/*
* Check that the user has one of the permission given
*/
Route::filter('has_perm', function () {
$permissions = array_slice(func_get_args(), 2);
$authentication_helper = App::make('authentication_helper');
if (!$authentication_helper->hasPermission($permissions)) {
App::abort('401');
}
});
/*
|--------------------------------------------------------------------------
| Other Filters
|--------------------------------------------------------------------------
|
*/
Route::filter('ajax', function () {
if (!Request::ajax()) {
return Response::error('404');
}
});
示例2: fault
/**
* This is method fault
*
* @param mixed $exception
* This is a description
* @param mixed $format
* This is a description
* @param mixed $httpCode
* This is a description
* @return mixed This is the return value description
*/
public function fault($exception = null, $format = 'json', $httpCode = null)
{
$error = false;
if ($exception instanceof OAuthException) {
$error = ['code' => $exception->getCode(), 'message' => $exception->getMessage()];
} else {
if ($exception instanceof \Exception) {
$error = ['code' => $exception->getCode(), 'message' => $exception->getMessage()];
} else {
$error = ['code' => BAD_URL, 'message' => static::getError(BAD_URL)];
}
}
switch ($format) {
case 'xml':
$errorXml = Response::error($error['code'], $error['message']);
return $errorXml;
case 'plain-text':
return Response::plain($error);
case 'json':
$errorXml = Response::error($error['code'], $error['message'], false);
return Zend_Json::fromXml($errorXml);
}
}