Bundle/TwigBundle/Controller/ExceptionController.php
public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null, $_format = 'html')
    {
        $currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1));
        $code = $exception->getStatusCode();

        //get request extension
        $uriArray = explode('/', rtrim($request->getRequestUri(), '/'));

        $matches = preg_match('/^.*(\..*)$/', array_pop($uriArray), $matches);

        $locale = $request->getLocale();
        if (!in_array($locale, $this->availableLocales, true)) {
            $request->setLocale($this->defaultLocale);
        }
        //if in production environment and the query is not a file
        if ($this->debug === false && 0 === $matches) {
            $page = $this->em->getRepository('VictoireTwigBundle:ErrorPage')->findOneByCode($code);
            if ($page) {
                return $this->forward('VictoireTwigBundle:ErrorPage:show', [
                        'code' => $page->getCode(),
                ]);
            }
        }

        return new Response($this->twig->render(
            $this->findTemplate($request, $_format, $code, $this->debug),
            [
                'status_code'    => $code,
                'status_text'    => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
                'exception'      => $exception,
                'logger'         => $logger,
                'currentContent' => $currentContent,
            ]
        ));
    }
public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null, $_format = 'html')
    {
        $currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1));
        $code = $exception->getStatusCode();

        //get request extension
        $uriArray = explode('/', rtrim($request->getRequestUri(), '/'));

        $matches = preg_match('/^.*(\..*)$/', array_pop($uriArray), $matches);

        $locale = $request->getLocale();
        if (!in_array($locale, $this->availableLocales, true)) {
            $request->setLocale($this->defaultLocale);
        }
        //if in production environment and the query is not a file
        if ($this->debug === false && 0 === $matches) {
            $page = $this->em->getRepository('VictoireTwigBundle:ErrorPage')->findOneByCode($code);
            if ($page) {
                return $this->forward('VictoireTwigBundle:ErrorPage:show', [
                        'code' => $page->getCode(),
                ]);
            }
        }

        return new Response($this->twig->render(
            $this->findTemplate($request, $_format, $code, $this->debug),
            [
                'status_code'    => $code,
                'status_text'    => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
                'exception'      => $exception,
                'logger'         => $logger,
                'currentContent' => $currentContent,
            ]
        ));
    }
public function showAction ( Request $ request , FlattenException $ exception , DebugLoggerInterface $ logger = null , $ _format = 'html' ) { $ currentContent = $ this -> getAndCleanOutputBuffering ( $ request -> headers -> get ( 'X-Php-Ob-Level' , - 1 ) ) ; $ code = $ exception -> getStatusCode ( ) ; //get request extension $ uriArray = explode ( '/' , rtrim ( $ request -> getRequestUri ( ) , '/' ) ) ; $ matches = preg_match ( '/^.*(\..*)$/' , array_pop ( $ uriArray ) , $ matches ) ; $ locale = $ request -> getLocale ( ) ; if ( ! in_array ( $ locale , $ this -> availableLocales , true ) ) { $ request -> setLocale ( $ this -> defaultLocale ) ; } //if in production environment and the query is not a file if ( $ this -> debug === false && 0 === $ matches ) { $ page = $ this -> em -> getRepository ( 'VictoireTwigBundle:ErrorPage' ) -> findOneByCode ( $ code ) ; if ( $ page ) { return $ this -> forward ( 'VictoireTwigBundle:ErrorPage:show' , [ 'code' => $ page -> getCode ( ) , ] ) ; } } return new Response ( $ this -> twig -> render ( $ this -> findTemplate ( $ request , $ _format , $ code , $ this -> debug ) , [ 'status_code' => $ code , 'status_text' => isset ( Response :: $ statusTexts [ $ code ] ) ? Response :: $ statusTexts [ $ code ] : '' , 'exception' => $ exception , 'logger' => $ logger , 'currentContent' => $ currentContent , ] ) ) ; }
Converts an Exception to a Response to be able to render a Victoire view.

@param Request              $request   The request
@param FlattenException     $exception A FlattenException instance
@param DebugLoggerInterface $logger    A DebugLoggerInterface instance
@param string               $_format   The format to use for rendering (html, xml, ...)

@throws \InvalidArgumentException When the exception template does not exist

@return Response
Converts an Exception to a Response to be able to render a Victoire view .