<?php
namespace LoyxxSW6ConversionCheckout\Storefront\Controller;
use Shopware\Core\Checkout\Cart\SalesChannel\CartService;
use Shopware\Core\Checkout\Customer\SalesChannel\AbstractLoginRoute;
use Shopware\Core\Checkout\Customer\SalesChannel\AbstractLogoutRoute;
use Shopware\Core\Checkout\Customer\SalesChannel\AbstractResetPasswordRoute;
use Shopware\Core\Checkout\Customer\SalesChannel\AbstractSendPasswordRecoveryMailRoute;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\Routing\Annotation\RouteScope;
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Shopware\Core\System\SystemConfig\SystemConfigService;
use Shopware\Storefront\Page\Account\Login\AccountLoginPageLoader;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @RouteScope(scopes={"storefront"})
*/
class AuthController extends \Shopware\Storefront\Controller\AuthController
{
private AccountLoginPageLoader $loginPageLoader;
private EntityRepositoryInterface $customerRecoveryRepository;
private AbstractSendPasswordRecoveryMailRoute $sendPasswordRecoveryMailRoute;
private AbstractResetPasswordRoute $resetPasswordRoute;
private AbstractLoginRoute $loginRoute;
private AbstractLogoutRoute $logoutRoute;
private SystemConfigService $systemConfig;
private CartService $cartService;
public function __construct(
AccountLoginPageLoader $loginPageLoader,
EntityRepositoryInterface $customerRecoveryRepository,
AbstractSendPasswordRecoveryMailRoute $sendPasswordRecoveryMailRoute,
AbstractResetPasswordRoute $resetPasswordRoute,
AbstractLoginRoute $loginRoute,
AbstractLogoutRoute $logoutRoute,
CartService $cartService
)
{
parent::__construct(
$loginPageLoader,
$customerRecoveryRepository,
$sendPasswordRecoveryMailRoute,
$resetPasswordRoute,
$loginRoute,
$logoutRoute,
$cartService
);
$this->loginPageLoader = $loginPageLoader;
$this->customerRecoveryRepository = $customerRecoveryRepository;
$this->sendPasswordRecoveryMailRoute = $sendPasswordRecoveryMailRoute;
$this->resetPasswordRoute = $resetPasswordRoute;
$this->loginRoute = $loginRoute;
$this->logoutRoute = $logoutRoute;
$this->cartService = $cartService;
}
/**
* @Route("/account/login", name="frontend.account.login.page", methods={"GET"})
*/
public function loginPage(Request $request, RequestDataBag $data, SalesChannelContext $context): Response
{
/** @var string $redirect */
$redirect = $request->get('redirectTo', 'frontend.account.home.page');
$customer = $context->getCustomer();
if ($customer !== null && $customer->getGuest() === false) {
$request->request->set('redirectTo', $redirect);
return $this->createActionResponse($request);
}
$page = $this->loginPageLoader->load($request, $context);
$view = '@Storefront/storefront/page/account/register/index.html.twig';
if ($request->get('persistCheckoutWindow', false)){
$view = '@Storefront/storefront/page/checkout/address/index.html.twig';
}
return $this->renderStorefront($view, [
'redirectTo' => $redirect,
'redirectParameters' => $request->get('redirectParameters', json_encode([])),
'page' => $page,
'loginError' => (bool) $request->get('loginError'),
'errorSnippet' => $request->get('errorSnippet'),
'data' => $data,
]);
}
}