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

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\DataAbstractionLayer\EntityRepositoryInterface;
  9. use Shopware\Core\Framework\Routing\Annotation\RouteScope;
  10. use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
  11. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  12. use Shopware\Core\System\SystemConfig\SystemConfigService;
  13. use Shopware\Storefront\Page\Account\Login\AccountLoginPageLoader;
  14. use Symfony\Component\HttpFoundation\Request;
  15. use Symfony\Component\HttpFoundation\Response;
  16. use Symfony\Component\Routing\Annotation\Route;
  17. /**
  18.  * @RouteScope(scopes={"storefront"})
  19.  */
  20. class AuthController extends \Shopware\Storefront\Controller\AuthController
  21. {
  22.     private AccountLoginPageLoader $loginPageLoader;
  23.     private EntityRepositoryInterface $customerRecoveryRepository;
  24.     private AbstractSendPasswordRecoveryMailRoute $sendPasswordRecoveryMailRoute;
  25.     private AbstractResetPasswordRoute $resetPasswordRoute;
  26.     private AbstractLoginRoute $loginRoute;
  27.     private AbstractLogoutRoute $logoutRoute;
  28.     private SystemConfigService $systemConfig;
  29.     private CartService $cartService;
  30.     public function __construct(
  31.         AccountLoginPageLoader $loginPageLoader,
  32.         EntityRepositoryInterface $customerRecoveryRepository,
  33.         AbstractSendPasswordRecoveryMailRoute $sendPasswordRecoveryMailRoute,
  34.         AbstractResetPasswordRoute $resetPasswordRoute,
  35.         AbstractLoginRoute $loginRoute,
  36.         AbstractLogoutRoute $logoutRoute,
  37.         CartService $cartService
  38.     )
  39.     {
  40.         parent::__construct(
  41.             $loginPageLoader,
  42.             $customerRecoveryRepository,
  43.             $sendPasswordRecoveryMailRoute,
  44.             $resetPasswordRoute,
  45.             $loginRoute,
  46.             $logoutRoute,
  47.             $cartService
  48.         );
  49.         $this->loginPageLoader $loginPageLoader;
  50.         $this->customerRecoveryRepository $customerRecoveryRepository;
  51.         $this->sendPasswordRecoveryMailRoute $sendPasswordRecoveryMailRoute;
  52.         $this->resetPasswordRoute $resetPasswordRoute;
  53.         $this->loginRoute $loginRoute;
  54.         $this->logoutRoute $logoutRoute;
  55.         $this->cartService $cartService;
  56.     }
  57.     /**
  58.      * @Route("/account/login", name="frontend.account.login.page", methods={"GET"})
  59.      */
  60.     public function loginPage(Request $requestRequestDataBag $dataSalesChannelContext $context): Response
  61.     {
  62.         /** @var string $redirect */
  63.         $redirect $request->get('redirectTo''frontend.account.home.page');
  64.         $customer $context->getCustomer();
  65.         if ($customer !== null && $customer->getGuest() === false) {
  66.             $request->request->set('redirectTo'$redirect);
  67.             return $this->createActionResponse($request);
  68.         }
  69.         $page $this->loginPageLoader->load($request$context);
  70.         $view '@Storefront/storefront/page/account/register/index.html.twig';
  71.         if ($request->get('persistCheckoutWindow'false)){
  72.             $view '@Storefront/storefront/page/checkout/address/index.html.twig';
  73.         }
  74.         return $this->renderStorefront($view, [
  75.             'redirectTo' => $redirect,
  76.             'redirectParameters' => $request->get('redirectParameters'json_encode([])),
  77.             'page' => $page,
  78.             'loginError' => (bool) $request->get('loginError'),
  79.             'errorSnippet' => $request->get('errorSnippet'),
  80.             'data' => $data,
  81.         ]);
  82.     }
  83. }