Bolt\Controller\Frontend::before PHP Метод

before() публичный Метод

Refer to the routing.yml config file for overridding.
public before ( Request $request ) : null | TemplateResponse | RedirectResponse
$request Symfony\Component\HttpFoundation\Request The Symfony Request
Результат null | Bolt\Response\TemplateResponse | Symfony\Component\HttpFoundation\RedirectResponse
    public function before(Request $request)
    {
        // Start the 'stopwatch' for the profiler.
        $this->app['stopwatch']->start('bolt.frontend.before');
        // If there are no users in the users table, or the table doesn't exist.
        // Repair the DB, and let's add a new user.
        if (!$this->hasUsers()) {
            $this->flashes()->info(Trans::__('general.phrase.users-none-create-first'));
            return $this->redirectToRoute('userfirst');
        }
        // If we are in maintenance mode and current user is not logged in, show maintenance notice.
        if ($this->getOption('general/maintenance_mode')) {
            if (!$this->isAllowed('maintenance-mode')) {
                $template = $this->templateChooser()->maintenance();
                $response = $this->render($template);
                $response->setStatusCode(Response::HTTP_SERVICE_UNAVAILABLE);
                return $response;
            }
        }
        // Stop the 'stopwatch' for the profiler.
        $this->app['stopwatch']->stop('bolt.frontend.before');
        return null;
    }