當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Application::isDownForMaintenance方法代碼示例

本文整理匯總了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);
 }
開發者ID:revolverobotics,項目名稱:tools-laravel-microservice,代碼行數:16,代碼來源:CheckForMaintenanceMode.php

示例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);
 }
開發者ID:it-can,項目名稱:laravel-middlewares,代碼行數:16,代碼來源:CheckForMaintenanceMode.php

示例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);
 }
開發者ID:mubassirhayat,項目名稱:Laravel51-starter,代碼行數:14,代碼來源:CheckForMaintenanceMode.php

示例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);
 }
開發者ID:philcross,項目名稱:laravel-maintenance-mode,代碼行數:16,代碼來源:CheckForMaintenanceMode.php

示例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);
 }
開發者ID:berkapavel,項目名稱:CMS,代碼行數:15,代碼來源:CheckForMaintenanceMode.php

示例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);
 }
開發者ID:CodeWire,項目名稱:larapress,代碼行數:14,代碼來源:MaintenanceMiddleware.php

示例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);
 }
開發者ID:jacksun101,項目名稱:streams-platform,代碼行數:37,代碼來源:CheckForMaintenanceMode.php

示例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);
 }
開發者ID:nekonekonik,項目名稱:nuswhispers,代碼行數:14,代碼來源:CheckForMaintenanceMode.php

示例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);
 }
開發者ID:notadd,項目名稱:framework,代碼行數:17,代碼來源:CheckForMaintenanceMode.php

示例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);
 }
開發者ID:projnoah,項目名稱:noah,代碼行數:19,代碼來源:CheckForMaintenanceMode.php

示例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'));
     }
 }
開發者ID:jacksun101,項目名稱:settings-module,代碼行數:19,代碼來源:UpdateMaintenanceMode.php

示例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);
 }
開發者ID:pedrohbraz,項目名稱:rifasPando,代碼行數:23,代碼來源:ModoManutencao.php

示例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());
 }
開發者ID:rosswilson252,項目名稱:framework,代碼行數:13,代碼來源:Event.php

示例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);
 }
開發者ID:brahmantyo,項目名稱:master,代碼行數:79,代碼來源:CheckForMaintenanceMode.php

示例15: filter

 /**
  * Run the request filter.
  *
  * @return mixed
  */
 public function filter()
 {
     if ($this->app->isDownForMaintenance()) {
         return new Response('Be right back!', 503);
     }
 }
開發者ID:devLopez,項目名稱:espresso,代碼行數:11,代碼來源:MaintenanceFilter.php


注:本文中的Illuminate\Contracts\Foundation\Application::isDownForMaintenance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。