]> Raphaƫl G. Git Repositories - airbundle/blobdiff - Controller/ErrorController.php
New layout with header
[airbundle] / Controller / ErrorController.php
index eb5320997f4176b61c7ca6e9bc975679291b9f81..72e108f65307a3ec7aef2a9cf17a032bb8e7da00 100644 (file)
@@ -18,18 +18,47 @@ class ErrorController extends DefaultController {
        /**
         * {@inheritdoc}
         */
        /**
         * {@inheritdoc}
         */
-       public function preview(Request $request, FlattenException $exception) {
+       public function show(Request $request, FlattenException $exception) {
                //Set section
                $section = $exception->getStatusCode().' '.$this->translator->trans($exception->getStatusText());
 
                //Set title
                //Set section
                $section = $exception->getStatusCode().' '.$this->translator->trans($exception->getStatusText());
 
                //Set title
-               $title = $section.' - '.$this->translator->trans($this->config['site']['title']);
+               $title = $this->translator->trans($this->config['site']['title']).' - '.$section;
 
                //Set the message
                $message = $exception->getMessage();
 
 
                //Set the message
                $message = $exception->getMessage();
 
-               //Set the trace
-               $trace = $exception->getAsString();
+               //Init trace
+               $trace = null;
+
+               //Prevent non admin access to trace
+               if ($this->isGranted('ROLE_ADMIN')) {
+                       //Set project dir
+                       $projectDir = $this->container->getParameter('kernel.project_dir').'/';
+
+                       //Set the trace
+                       //$trace = $exception->getAsString();
+                       $trace = '';
+
+                       //Iterate on array
+                       foreach($exception->toArray() as $current) {
+                               $trace .= $current['class'];
+
+                               if (!empty($current['message'])) {
+                                       $trace .= ': '.$current['message'];
+                               }
+
+                               if (!empty($current['trace'])) {
+                                       foreach($current['trace'] as $id => $sub) {
+                                               $trace .= "\n".'#'.$id.' '.$sub['class'].$sub['type'].$sub['function'];
+                                               if (!empty($sub['args'])) {
+                                                       $trace .= '('.implode(', ', array_map(function($v){return $v[0].' '.$v[1];}, $sub['args'])).')';
+                                               }
+                                               $trace .= ' in '.str_replace($projectDir, '', $sub['file']).':'.$sub['line'];
+                                       }
+                               }
+                       }
+               }
 
                //Render template
                return $this->render(
 
                //Render template
                return $this->render(