a33853f727badd875cd7b1593e2c64cf38a12ca0
[yaffs-website] / http-kernel / EventListener / ValidateRequestListener.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\HttpKernel\EventListener;
13
14 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
15 use Symfony\Component\HttpKernel\Event\GetResponseEvent;
16 use Symfony\Component\HttpKernel\KernelEvents;
17
18 /**
19  * Validates Requests.
20  *
21  * @author Magnus Nordlander <magnus@fervo.se>
22  */
23 class ValidateRequestListener implements EventSubscriberInterface
24 {
25     /**
26      * Performs the validation.
27      */
28     public function onKernelRequest(GetResponseEvent $event)
29     {
30         if (!$event->isMasterRequest()) {
31             return;
32         }
33         $request = $event->getRequest();
34
35         if ($request::getTrustedProxies()) {
36             $request->getClientIps();
37         }
38
39         $request->getHost();
40     }
41
42     /**
43      * {@inheritdoc}
44      */
45     public static function getSubscribedEvents()
46     {
47         return array(
48             KernelEvents::REQUEST => array(
49                 array('onKernelRequest', 256),
50             ),
51         );
52     }
53 }