SkautisExceptionListener::onKernelException()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
namespace SkautisBundle\EventListener;
4
5
use Symfony\Component\HttpFoundation\RedirectResponse;
6
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
7
8
/**
9
 * Listener pro zpracovani neosetrenych \Skautis\Exception
10
 */
11
class SkautisExceptionListener
12
{
13
    /**
14
     * Kontrola zda tento listener obsluhuje dany typ exceptionu
15
     */
16
    protected function supportsException(\Exception $exception)
17
    {
18
        return $exception instanceof \Skautis\Exception;
19
    }
20
21
    /**
22
     * Obsluha vyjimky
23
     */
24
    public function onKernelException(GetResponseForExceptionEvent $event)
25
    {
26
        $exception = $event->getException();
27
        if (!$this->supportsException($exception)) {
28
            return;
29
        }
30
31
        $response = new RedirectResponse("skautis/error");
32
        $event->setResponse($response);
33
    }
34
35
}