Completed
Push — master ( 3a8823...81c6e7 )
by Piotr
02:46
created

Handler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handleRequest() 0 11 3
1
<?php
2
3
/**
4
 * (c) FSi sp. z o.o. <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace FSi\Bundle\AdminBundle\Admin\Display\Context\Request;
11
12
use FSi\Bundle\AdminBundle\Admin\Context\Request\AbstractHandler;
13
use FSi\Bundle\AdminBundle\Event\AdminEvent;
14
use FSi\Bundle\AdminBundle\Event\DisplayEvent;
15
use FSi\Bundle\AdminBundle\Event\DisplayEvents;
16
use FSi\Bundle\AdminBundle\Exception\RequestHandlerException;
17
use Symfony\Component\HttpFoundation\Request;
18
19
class Handler extends AbstractHandler
20
{
21
    /**
22
     * @param AdminEvent $event
23
     * @param Request $request
24
     * @throws \FSi\Bundle\AdminBundle\Exception\RequestHandlerException
25
     * @return null|\Symfony\Component\HttpFoundation\Response
26
     */
27
    public function handleRequest(AdminEvent $event, Request $request)
28
    {
29
        if (!$event instanceof DisplayEvent) {
30
            throw new RequestHandlerException(sprintf("%s require DisplayEvent", get_class($this)));
31
        }
32
33
        $this->eventDispatcher->dispatch(DisplayEvents::DISPLAY_PRE_RENDER, $event);
34
        if ($event->hasResponse()) {
35
            return $event->getResponse();
36
        }
37
    }
38
}
39