public function register(Container $app) { $app['maintenance.enabled'] = false; if ($this->isMaintenanceMode) { $app['maintenance.enabled'] = true; if ($this->htmlFile) { $app['maintenance.html'] = file_get_contents($this->htmlFile); $app->match('/{path}', function () use($app) { return new Response($app['maintenance.html'], 503); })->assert('path', '.*'); } elseif (isset($app['twig']) && $this->twigTemplate) { $app['maintenance.twig_template'] = $this->twigTemplate; $app->match('/{path}', function () use($app) { $response = new Response(); $response->setStatusCode(503); $response->setContent($app['twig']->render($app['maintenance.twig_template'])); return $response; })->assert('path', '.*'); } else { $app->match('/{path}', function () use($app) { return $app->abort(503); })->assert('path', '.*'); } } }