shouldRedirectToInstaller example


  protected function handleException(\Exception $e$request$type) {
    if ($this->shouldRedirectToInstaller($e$this->container ? $this->container->get('database') : NULL)) {
      return new RedirectResponse($request->getBasePath() . '/core/install.php', 302, ['Cache-Control' => 'no-cache']);
    }

    if ($e instanceof HttpExceptionInterface) {
      $response = new Response($e->getMessage()$e->getStatusCode());
      $response->headers->add($e->getHeaders());
      return $response;
    }

    throw $e;
  }

  
$this->connection = $connection;
  }

  /** * Handles errors for this subscriber. * * @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event * The event to process. */
  public function onException(ExceptionEvent $event) {
    $exception = $event->getThrowable();
    if ($this->shouldRedirectToInstaller($exception$this->connection)) {
      // Only redirect if this is an HTML response (i.e., a user trying to view       // the site in a web browser before installing it).       $request = $event->getRequest();
      $format = $request->query->get(MainContentViewSubscriber::WRAPPER_FORMAT, $request->getRequestFormat());
      if ($format == 'html') {
        $event->setResponse(new RedirectResponse($request->getBasePath() . '/core/install.php', 302, ['Cache-Control' => 'no-cache']));
      }
    }
  }

  /** * Registers the methods in this class that should be listeners. * * @return array * An array of event listener definitions. */
Home | Imprint | This part of the site doesn't use cookies.