ErrorController::findTemplate()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
rs 9.2
cc 4
eloc 10
nc 3
nop 4
1
<?php
2
namespace AppBundle\Controller;
3
4
use Symfony\Bundle\TwigBundle\Controller\ExceptionController;
5
use Symfony\Component\HttpFoundation\Request;
6
7
class ErrorController extends ExceptionController
8
{
9
    protected function findTemplate(Request $request, $format, $code, $showException)
10
    {
11
        if (!$showException) {
12
            $templates = [
13
                sprintf('%s.%s.twig', $code, $format),
14
                sprintf('%sxx.%s.twig', substr($code, 0, 1), $format),
15
            ];
16
17
            foreach ($templates as $template) {
18
                $templateFile = '_error/'.$template;
19
                if ($this->templateExists($templateFile)) {
20
                    return $templateFile;
21
                }
22
            }
23
        }
24
25
        return parent::findTemplate($request, $format, $code, $showException);
26
    }
27
}
28