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

Handler::handleRequest()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 2
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