本文整理汇总了PHP中Illuminate\Contracts\Foundation\Application::isDownForMaintenance方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::isDownForMaintenance方法的具体用法?PHP Application::isDownForMaintenance怎么用?PHP Application::isDownForMaintenance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\Foundation\Application
的用法示例。
在下文中一共展示了Application::isDownForMaintenance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/
public function handle($request, Closure $next)
{
if ($this->app->isDownForMaintenance() && $this->app->environment() != 'testing') {
throw new HttpException(503, 'Server is currently undergoing maintenance. We should be ' . 'back up shortly.');
}
return $next($request);
}
示例2: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/
public function handle($request, Closure $next)
{
if ($this->app->isDownForMaintenance()) {
throw new HttpException(503, null, null, ['Retry-After' => 900]);
}
return $next($request);
}
示例3: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->app->isDownForMaintenance()) {
throw new HttpException(503);
}
return $next($request);
}
示例4: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/
public function handle(Request $request, Closure $next)
{
if ($this->app->isDownForMaintenance() && !in_array($request->getClientIp(), config('maintenance.ips', [])) && (config('maintenance.bypass_with_cookie', false) === false || config('maintenance.cookie_name', '') === '' || !$request->hasCookie(config('maintenance.cookie_name')))) {
throw new HttpException(503);
}
return $next($request);
}
示例5: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->app->isDownForMaintenance()) {
return new Response($this->view->make('maintenance')->render(), 503);
}
return $next($request);
}
示例6: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->app->isDownForMaintenance()) {
return new Response('Be right back!', 503);
}
return $next($request);
}
示例7: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return void|mixed
*/
public function handle(Request $request, Closure $next)
{
if (!$this->app->isDownForMaintenance()) {
return $next($request);
}
if ($request->segment(1) == 'admin') {
return $next($request);
}
if (in_array($request->getClientIp(), $this->config->get('streams::maintenance.ip_whitelist', []))) {
return $next($request);
}
/* @var UserInterface $user */
$user = $this->guard->user();
if ($user && $user->isAdmin()) {
return $next($request);
}
if ($user && $this->authorizer->authorize('streams::maintenance.access')) {
return $next($request);
}
if (!$user && $this->config->get('streams::maintenance.auth')) {
/* @var Response|null $response */
$response = $this->guard->onceBasic();
if (!$response) {
return $next($request);
}
$response->setContent(view('streams::errors.401'));
return $response;
}
abort(503);
}
示例8: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->app->isDownForMaintenance() && !in_array($request->getClientIp(), ['127.0.0.1'])) {
throw new HttpException(503);
}
return $next($request);
}
示例9: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->application->isDownForMaintenance()) {
$data = json_decode(file_get_contents($this->application->storagePath() . '/bootstraps/down'), true);
throw new MaintenanceModeException($data['time'], $data['retry'], $data['message']);
}
return $next($request);
}
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/
public function handle($request, Closure $next)
{
if ($this->app->isDownForMaintenance()) {
if (site('adminIgnoresMaintenance') == '1' && ($user = $request->user()) && $user->isAdmin()) {
return $next($request);
}
throw new HttpException(503);
}
return $next($request);
}
示例11: handle
/**
* Handle the command.
*
* @param SettingsWereSaved $event
*/
public function handle(SettingsWereSaved $event)
{
$builder = $event->getBuilder();
if (!($namespace = $builder->getEntry()) == 'streams') {
return;
}
$maintenance = $builder->getFormValue('maintenance');
if ($maintenance && !$this->application->isDownForMaintenance()) {
touch(storage_path('framework/down'));
}
if (!$maintenance && $this->application->isDownForMaintenance()) {
unlink(storage_path('framework/down'));
}
}
示例12: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/
public function handle($request, Closure $next)
{
if ($this->app->isDownForMaintenance()) {
$response = $next($request);
$route = $request->route();
if ($route instanceof Route) {
if (in_array($route->getName(), $this->excludedRoutes)) {
return $response;
}
}
throw new HttpException(503);
}
return $next($request);
}
示例13: isDue
/**
* Determine if the given event should run based on the Cron expression.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return bool
*/
public function isDue($app)
{
if (!$this->runsInMaintenanceMode() && $app->isDownForMaintenance()) {
return false;
}
return $this->expressionPasses() && $this->runsInEnvironment($app->environment());
}
示例14: handle
/**
* Handle the request
*
* @param \Illuminate\Http\Request $request
* @param callable $next
* @return Response
* @throws ExemptionDoesNotExist
* @throws InvalidExemption
*/
public function handle($request, Closure $next)
{
// Grab our configs
$injectGlobally = $this->app['config']->get('maintenancemode.inject.globally', true);
$prefix = $this->app['config']->get('maintenancemode.inject.prefix', 'MaintenanceMode');
$lang = $this->app['config']->get('maintenancemode.language-path', 'maintenancemode::defaults');
// Setup value array
$info = [$prefix . 'Enabled' => false, $prefix . 'Timestamp' => Carbon::now(), $prefix . 'Message' => $this->app['translator']->get($lang . '.message')];
// Are we down?
if ($this->app->isDownForMaintenance()) {
// Yes. :(
$info[$prefix . 'Enabled'] = true;
$path = storage_path() . '/framework/down';
if ($this->app['files']->exists($path)) {
// Grab the stored information
$fileContents = $this->app['files']->get($path);
if (preg_match('~([0-9]+)\\|(.*)~', $fileContents, $matches)) {
// And put it into our array, if it exists
$info[$prefix . 'Timestamp'] = Carbon::createFromTimeStamp($matches[1]);
if (isset($matches[2]) && $matches[2] != '') {
$info[$prefix . 'Message'] = $matches[2];
}
}
}
if ($injectGlobally) {
// Inject the information globally
foreach ($info as $key => $value) {
$this->app['view']->share($key, $value);
}
}
// Check to see if the user is exempt or not
$isExempt = false;
// Grab all of the exemption classes to create/execute against
$exemptions = $this->app['config']->get('maintenancemode.exemptions', []);
foreach ($exemptions as $className) {
if (class_exists($className)) {
$exemption = new $className($this->app);
if ($exemption instanceof MaintenanceModeExemption) {
// Run the exemption check
if ($exemption->isExempt()) {
$isExempt = true;
break;
}
} else {
// Class doesn't match what we're looking for
throw new InvalidExemption($this->app['translator']->get($lang . '.exceptions.invalid', ['class' => $className]));
}
} else {
// Where's Waldo?
throw new ExemptionDoesNotExist($this->app['translator']->get($lang . '.exceptions.missing', ['class' => $className]));
}
}
if (!$isExempt) {
// Since the session isn't started... it'll throw an error
$this->app['session']->start();
// The user isn't exempt, let's show them the maintenance page!
$view = $this->app['config']->get('maintenancemode.view-page', 'maintenancemode::app-down');
// $view = 'errors.503';
return new Response(view($view, $info), 503);
}
} else {
if ($injectGlobally) {
// Inject the information globally (to prevent the need of isset)
foreach ($info as $key => $value) {
$this->app['view']->share($key, $value);
}
}
}
return $next($request);
}
示例15: filter
/**
* Run the request filter.
*
* @return mixed
*/
public function filter()
{
if ($this->app->isDownForMaintenance()) {
return new Response('Be right back!', 503);
}
}