src/EventSubscriber/LoginSubscriber.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  4. use Symfony\Component\HttpKernel\Event\GetResponseEvent;
  5. use Symfony\Component\HttpKernel\Event\RequestEvent;
  6. use Symfony\Component\HttpKernel\KernelEvents;
  7. class LoginSubscriber implements EventSubscriberInterface
  8. {
  9.     /**
  10.      * @param RequestEvent $event
  11.      */
  12.     public function onKernelRequest(RequestEvent $event)
  13.     {
  14.         if ('login' === $event->getRequest()->attributes->get('_route')) {
  15.             $username $event->getRequest()->request->get('_username');
  16.             $event->getRequest()->request->set('_username'trim($username));
  17.             $event->getRequest()->request->set('_password'trim($event->getRequest()->request->get('_password')));
  18.             return;
  19.         }
  20.     }
  21.     public static function getSubscribedEvents()
  22.     {
  23.         return [
  24.             KernelEvents::REQUEST => ['onKernelRequest'9]
  25.         ];
  26.     }
  27. }