Bolt\Controller\Exception::databaseConnect PHP Method

databaseConnect() public method

public databaseConnect ( string $platform, Exception $previous ) : Response
$platform string
$previous Exception
return Symfony\Component\HttpFoundation\Response
    public function databaseConnect($platform, \Exception $previous)
    {
        if ($this->app === null) {
            throw new \RuntimeException('Exception controller being used outside of request cycle.');
        }
        $context = $this->getContextArray($previous);
        $context['type'] = 'connect';
        $context['platform'] = $platform;
        $html = $this->app['twig']->render('@bolt/exception/database/exception.twig', $context);
        $response = new Response($html);
        return new Response($response, Response::HTTP_OK);
    }

Usage Example

Example #1
0
 /**
  * Event fired on database connection failure.
  *
  * @param FailedConnectionEvent $args
  *
  * @throws BootException
  */
 public function failConnect(FailedConnectionEvent $args)
 {
     $e = $args->getException();
     $this->logger->debug($e->getMessage(), ['event' => 'exception', 'exception' => $e]);
     /*
      * Using Driver here since Platform may try to connect
      * to the database, which has failed since we are here.
      */
     $platform = $args->getDriver()->getName();
     $platform = Str::replaceFirst('pdo_', '', $platform);
     $response = $this->exceptionController->databaseConnect($platform, $e);
     throw new BootException($e->getMessage(), $e->getCode(), $e, $response);
 }