custom/plugins/LoyxxSW6ConversionCheckout/src/Storefront/Controller/AuthController.php line 99

Open in your IDE?
  1. <?php
  2. namespace LoyxxSW6ConversionCheckout\Storefront\Controller;
  3. use Shopware\Core\Checkout\Cart\SalesChannel\CartService;
  4. use Shopware\Core\Checkout\Customer\SalesChannel\AbstractLoginRoute;
  5. use Shopware\Core\Checkout\Customer\SalesChannel\AbstractLogoutRoute;
  6. use Shopware\Core\Checkout\Customer\SalesChannel\AbstractResetPasswordRoute;
  7. use Shopware\Core\Checkout\Customer\SalesChannel\AbstractSendPasswordRecoveryMailRoute;
  8. use Shopware\Core\Framework\Routing\Annotation\Since;
  9. use Shopware\Core\System\SalesChannel\Context\SalesChannelContextServiceInterface;
  10. use Shopware\Storefront\Checkout\Cart\SalesChannel\StorefrontCartFacade;
  11. use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
  12. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  13. use Shopware\Core\System\SystemConfig\SystemConfigService;
  14. use Shopware\Storefront\Framework\Routing\Annotation\NoStore;
  15. use Shopware\Storefront\Page\Account\Login\AccountLoginPageLoader;
  16. use Shopware\Storefront\Page\Account\RecoverPassword\AccountRecoverPasswordPageLoader;
  17. use Symfony\Component\HttpFoundation\Request;
  18. use Symfony\Component\HttpFoundation\Response;
  19. use Symfony\Component\Routing\Annotation\Route;
  20. /**
  21.  * @Route(defaults={"_routeScope"={"storefront"}})
  22.  */
  23. class AuthController extends \Shopware\Storefront\Controller\AuthController
  24. {
  25.     private AccountLoginPageLoader $loginPageLoader;
  26.     private AbstractSendPasswordRecoveryMailRoute $sendPasswordRecoveryMailRoute;
  27.     private AbstractResetPasswordRoute $resetPasswordRoute;
  28.     private AbstractLoginRoute $loginRoute;
  29.     private AbstractLogoutRoute $logoutRoute;
  30.     private StorefrontCartFacade $cartFacade;
  31.     private SystemConfigService $systemConfig;
  32.     private AccountRecoverPasswordPageLoader $recoverPasswordPageLoader;
  33.     
  34.     private SalesChannelContextServiceInterface $salesChannelContextService;
  35.     public function __construct(
  36.         AccountLoginPageLoader                $loginPageLoader,
  37.         AbstractSendPasswordRecoveryMailRoute $sendPasswordRecoveryMailRoute,
  38.         AbstractResetPasswordRoute            $resetPasswordRoute,
  39.         AbstractLoginRoute                    $loginRoute,
  40.         AbstractLogoutRoute                   $logoutRoute,
  41.         StorefrontCartFacade                  $cartFacade,
  42.         AccountRecoverPasswordPageLoader      $recoverPasswordPageLoader,
  43.         SalesChannelContextServiceInterface   $salesChannelContextService
  44.     )
  45.     {
  46.         parent::__construct(
  47.             $loginPageLoader,
  48.             $sendPasswordRecoveryMailRoute,
  49.             $resetPasswordRoute,
  50.             $loginRoute,
  51.             $logoutRoute,
  52.             $cartFacade,
  53.             $recoverPasswordPageLoader,
  54.             $salesChannelContextService
  55.         );
  56.         $this->loginPageLoader $loginPageLoader;
  57.         $this->sendPasswordRecoveryMailRoute $sendPasswordRecoveryMailRoute;
  58.         $this->resetPasswordRoute $resetPasswordRoute;
  59.         $this->loginRoute $loginRoute;
  60.         $this->logoutRoute $logoutRoute;
  61.         $this->cartFacade $cartFacade;
  62.         $this->recoverPasswordPageLoader $recoverPasswordPageLoader;
  63.         $this->salesChannelContextService $salesChannelContextService;
  64.     }
  65.     /**
  66.      * @Since("6.0.0.0")
  67.      * @Route("/account/login", name="frontend.account.login.page", methods={"GET"})
  68.      * @NoStore
  69.      */
  70.     public function loginPage(Request $requestRequestDataBag $dataSalesChannelContext $context): Response
  71.     {
  72.         /** @var string $redirect */
  73.         $redirect $request->get('redirectTo''frontend.account.home.page');
  74.         $customer $context->getCustomer();
  75.         if ($customer !== null && $customer->getGuest() === false) {
  76.             $request->request->set('redirectTo'$redirect);
  77.             return $this->createActionResponse($request);
  78.         }
  79.         $page $this->loginPageLoader->load($request$context);
  80.         $view '@Storefront/storefront/page/account/register/index.html.twig';
  81.         if ($request->get('persistCheckoutWindow'false)) {
  82.             $view '@Storefront/storefront/page/checkout/address/index.html.twig';
  83.         }
  84.         return $this->renderStorefront($view, [
  85.             'redirectTo' => $redirect,
  86.             'redirectParameters' => $request->get('redirectParameters'json_encode([])),
  87.             'page' => $page,
  88.             'loginError' => (bool)$request->get('loginError'),
  89.             'errorSnippet' => $request->get('errorSnippet'),
  90.             'data' => $data,
  91.         ]);
  92.     }
  93. }