public function __construct( private readonly NewsletterSubscribePageLoader
$newsletterConfirmRegisterPageLoader,
private readonly AbstractNewsletterConfirmRoute
$newsletterConfirmRoute,
private readonly NewsletterAccountPageletLoader
$newsletterAccountPageletLoader ) { } #[Route(path: '/newsletter-subscribe', name: 'frontend.newsletter.subscribe', methods: ['GET'])]
public function subscribeMail(SalesChannelContext
$context, Request
$request, QueryDataBag
$queryDataBag): Response
{ try { $this->newsletterConfirmRoute->
confirm($queryDataBag->
toRequestDataBag(),
$context);
} catch (NewsletterException
) { $this->
addFlash(self::DANGER,
$this->
trans('newsletter.subscriptionConfirmationFailed'
));
return $this->
forwardToRoute('frontend.home.page'
);
} catch (\Throwable
$throwable) { $this->
addFlash(self::DANGER,
$this->
trans('newsletter.subscriptionConfirmationFailed'
));
throw new \
Exception($throwable->
getMessage(),
$throwable->
getCode(),
$throwable);
} $page =
$this->newsletterConfirmRegisterPageLoader->
load($request,
$context);