src/PentagastBundle/Subscriber/KernelRequestSubscriber.php line 39

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. /**
  3.  * valantic CEC Deutschland GmbH
  4.  * Copyright (c) 2022.
  5.  *
  6.  * All rights reserved.
  7.  *
  8.  * @see https://www.valantic.com/
  9.  *
  10.  * @author andrei
  11.  * Date: 17.10.2022 17:10
  12.  */
  13. namespace Valantic\Bundle\PentagastBundle\Subscriber;
  14. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  15. use Symfony\Component\HttpKernel\Event\RequestEvent;
  16. use Symfony\Component\HttpKernel\KernelEvents;
  17. use Valantic\Bundle\PentagastBundle\Service\CartCheckoutGuard;
  18. use Valantic\Bundle\PentagastBundle\Service\UserLoginGuard;
  19. use Valantic\Bundle\PentagastBundle\Service\UserRegistrationGuard;
  20. class KernelRequestSubscriber implements EventSubscriberInterface
  21. {
  22.     public function __construct(
  23.         private UserRegistrationGuard $registrationGuard,
  24.         private UserLoginGuard $loginGuard,
  25.         private CartCheckoutGuard $cartCheckoutGuard
  26.     ) {
  27.     }
  28.     public static function getSubscribedEvents(): array
  29.     {
  30.         return [
  31.             KernelEvents::REQUEST => ['onKernelRequest', -250],
  32.         ];
  33.     }
  34.     public function onKernelRequest(RequestEvent $event): void
  35.     {
  36.         $request $event->getRequest();
  37.         $this->registrationGuard?->validate($request);
  38.         $this->loginGuard?->validate($request);
  39.         $this->cartCheckoutGuard?->validate($request);
  40.     }
  41. }