]> Raphaƫl G. Git Repositories - airbundle/blob - Controller/ErrorController.php
Add creator copyright infos
[airbundle] / Controller / ErrorController.php
1 <?php
2
3 namespace Rapsys\AirBundle\Controller;
4
5 use Symfony\Component\HttpFoundation\Request;
6 use Symfony\Component\HttpFoundation\Response;
7 #use Symfony\Component\Security\Core\Exception\AccessDeniedException;
8 #use Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface;
9 #use Symfony\Component\DependencyInjection\ContainerInterface;
10 #use Symfony\Component\Routing\RouterInterface;
11 #use Symfony\Component\Translation\TranslatorInterface;
12 #use Twig\Environment;
13
14 #use Symfony\Component\Debug\Exception\FlattenException;
15 use Symfony\Component\ErrorHandler\Exception\FlattenException;
16
17 class ErrorController extends DefaultController {
18 /**
19 * {@inheritdoc}
20 */
21 public function preview(Request $request, FlattenException $exception) {
22 //Set section
23 $section = $exception->getStatusCode().' '.$this->translator->trans($exception->getStatusText());
24
25 //Set title
26 $title = $this->translator->trans($this->config['site']['title']).' - '.$section;
27
28 //Set the message
29 $message = $exception->getMessage();
30
31 //Set the trace
32 $trace = $exception->getAsString();
33
34 //Render template
35 return $this->render(
36 '@RapsysAir/error.html.twig',
37 ['title' => $title, 'section' => $section, 'message' => $message, 'trace' => $trace]+$this->context
38 );
39 }
40 }