vendor/symfony/http-kernel/EventListener/ValidateRequestListener.php line 30

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