src/PentagastBundle/Service/UserRegistrationGuard.php line 34

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 16:43
  12.  */
  13. namespace Valantic\Bundle\PentagastBundle\Service;
  14. use Symfony\Component\HttpFoundation\Request;
  15. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  16. class UserRegistrationGuard extends ShopFeatureGuardBase
  17. {
  18.     public const USER_REGISTRATION_ROUTES = [
  19.         'frontend.account.register.page',       // GET  /account/register
  20.         'frontend.account.register.save',       // POST /account/register
  21.         'store-api.account.register',           // POST /store-api/account/register
  22.         'store-api.account.register.confirm',   // POST /store-api/account/register-confirm
  23.         //'frontend.checkout.register.page',      // GET  /checkout/register
  24.         'frontend.account.register.mail',       // GET  /registration/confirm
  25.         'store-api.account.register.confirm',   // POST /store-api/account/register-confirm
  26.     ];
  27.     /**
  28.      * @throws NotFoundHttpException
  29.      */
  30.     public function validate(Request $request): void
  31.     {
  32.         $route $request->attributes->get('_route');
  33.         $salesChannelContext $this->getSalesChannelContext($request);
  34.         if ($route && $salesChannelContext && !$this->shopFeaturesService->registrationEnabled($salesChannelContext)) {
  35.             if (\in_array($routeself::USER_REGISTRATION_ROUTEStrue) && !$this->shopFeaturesService->loginEnabled($salesChannelContext)) {
  36.                 throw new NotFoundHttpException();
  37.             }
  38.         }
  39.     }
  40. }