| Conditions | 6 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 4 |
| CRAP Score | 6 |
| Changes | 3 | ||
| Bugs | 2 | Features | 0 |
| 1 | <?php |
||
| 33 | public function handle(Request $request, Closure $next) |
||
| 34 | { |
||
| 35 | $siteDown = $this->app->isDownForMaintenance(); |
||
| 36 | $isLogin = $request->is('/', 'logout', 'signin'); |
||
| 37 | |||
| 38 | // Allow admin & login page to always view the site event in maintenance mode |
||
| 39 | if ($siteDown && !$isLogin && ($this->auth->guest() || !$this->getLoggedUser()->isAdmin())) { |
||
| 40 | throw new HttpException(503); |
||
| 41 | } |
||
| 42 | |||
| 43 | // Show message to administrator |
||
| 44 | 63 | if ($siteDown) { |
|
| 45 | $this->app['session']->flash('notice-error', trans('tinyissue.site_maintenance_message')); |
||
| 46 | 63 | } |
|
| 47 | 63 | ||
| 48 | 63 | return $next($request); |
|
| 49 | } |
||
| 50 | } |
||
| 51 |