]> Raphaƫl G. Git Repositories - airbundle/blobdiff - Controller/ErrorController.php
Add error controller
[airbundle] / Controller / ErrorController.php
diff --git a/Controller/ErrorController.php b/Controller/ErrorController.php
new file mode 100644 (file)
index 0000000..eb53209
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+
+namespace Rapsys\AirBundle\Controller;
+
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
+#use Symfony\Component\Security\Core\Exception\AccessDeniedException;
+#use Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface;
+#use Symfony\Component\DependencyInjection\ContainerInterface;
+#use Symfony\Component\Routing\RouterInterface;
+#use Symfony\Component\Translation\TranslatorInterface;
+#use Twig\Environment;
+
+#use Symfony\Component\Debug\Exception\FlattenException;
+use Symfony\Component\ErrorHandler\Exception\FlattenException;
+
+class ErrorController extends DefaultController {
+       /**
+        * {@inheritdoc}
+        */
+       public function preview(Request $request, FlattenException $exception) {
+               //Set section
+               $section = $exception->getStatusCode().' '.$this->translator->trans($exception->getStatusText());
+
+               //Set title
+               $title = $section.' - '.$this->translator->trans($this->config['site']['title']);
+
+               //Set the message
+               $message = $exception->getMessage();
+
+               //Set the trace
+               $trace = $exception->getAsString();
+
+               //Render template
+               return $this->render(
+                       '@RapsysAir/error.html.twig',
+                       ['title' => $title, 'section' => $section, 'message' => $message, 'trace' => $trace]+$this->context
+               );
+       }
+}