本文整理汇总了PHP中Illuminate\Foundation\Application::abort方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::abort方法的具体用法?PHP Application::abort怎么用?PHP Application::abort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Foundation\Application
的用法示例。
在下文中一共展示了Application::abort方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getReset
public function getReset($token = null)
{
if (is_null($token)) {
$this->application->abort(404);
}
return $this->view->make('UserManagement::password.reset')->with('token', $token);
}
示例2: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, \Closure $next)
{
// Check if the user is logged in
if (!$this->auth->check()) {
// Store the current uri in the session
$this->session->put('url.intended', $this->request->url());
// Redirect to the login page
return $this->redirect->route('login');
}
// Check if the user has access to the dashboard page
if (!$this->auth->hasAccess('dashboard.index')) {
// Show the insufficient permissions page
return $this->application->abort(403);
}
return $next($request);
}
示例3: viewCss
/**
* Controller function to output the CSS.
*
* @param Route $route
* @param Request $request
* @param Response $response
*
* @return Response
*/
public function viewCss(Route $route, Request $request, Response $response)
{
if (!$this->isResponseObject($response)) {
return $response;
}
$files = explode(',', $route->parameter('files', ''));
if ($route->parameter('count', 0) != count($files)) {
$this->app->abort(422, 'Length option incorrect');
}
}
示例4: routeNeedsRoleOrPermission
/**
* Filters a route for role(s) and/or permission(s).
*
* If the third parameter is null then abort with status code 403.
* Otherwise the $result is returned.
*
* @param string $route Route pattern. i.e: "admin/*"
* @param array|string $roles The role(s) needed
* @param array|string $permissions The permission(s) needed
* @param mixed $result i.e: Redirect::to('/')
* @param bool $requireAll User must have all roles and permissions
*
* @return void
*/
public function routeNeedsRoleOrPermission($route, $roles, $permissions, $result = null, $requireAll = false)
{
$filterName = is_array($roles) ? implode('_', $roles) : $roles;
$filterName .= '_' . (is_array($permissions) ? implode('_', $permissions) : $permissions);
$filterName .= '_' . substr(md5($route), 0, 6);
$closure = function () use($roles, $permissions, $result, $requireAll) {
$hasRole = $this->hasRole($roles, $requireAll);
$hasPerms = $this->can($permissions, $requireAll);
if ($requireAll) {
$hasRolePerm = $hasRole && $hasPerms;
} else {
$hasRolePerm = $hasRole || $hasPerms;
}
if (!$hasRolePerm) {
return empty($result) ? $this->app->abort(403) : $result;
}
};
// Same as Route::filter, registers a new filter
$this->app->router->filter($filterName, $closure);
// Same as Route::when, assigns a route pattern to the
// previously created filter.
$this->app->router->when($route, $filterName);
}
示例5: abort
/**
* Throw an HttpException with the given data.
*
* @param int $code
* @param string $message
* @param array $headers
* @return void
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
* @static
*/
public static function abort($code, $message = '', $headers = array())
{
\Illuminate\Foundation\Application::abort($code, $message, $headers);
}
示例6: checkPageStatus
/**
*
*/
private function checkPageStatus()
{
if ($this->page->is_trashed || !$this->page->is_visible || $this->page->is_hidden) {
$this->app->abort('404');
}
}