isNewsletterDoi example

            if ($recipient->getStatus() !== self::STATUS_OPT_OUT && $recipient->getConfirmedAt()) {
                return new NoContentResponse();
            }
        }

        $data = $this->completeData($data$context);

        $this->newsletterRecipientRepository->upsert([$data]$context->getContext());

        $recipient = $this->getNewsletterRecipient('email', $data['email']$context->getContext());

        if (!$this->isNewsletterDoi($context)) {
            $event = new NewsletterConfirmEvent($context->getContext()$recipient$context->getSalesChannel()->getId());
            $this->eventDispatcher->dispatch($event);

            return new NoContentResponse();
        }

        $hashedEmail = hash('sha1', $data['email']);
        $url = $this->getSubscribeUrl($context$hashedEmail$data['hash']$data$recipient);

        $event = new NewsletterRegisterEvent($context->getContext()$recipient$url$context->getSalesChannel()->getId());
        $this->eventDispatcher->dispatch($event);

        
protected function subscribe(RequestDataBag $dataBag, CustomerEntity $customer, SalesChannelContext $context, NewsletterAccountPagelet $newsletterAccountPagelet): NewsletterAccountPagelet
    {
        try {
            $this->newsletterSubscribeRoute->subscribe(
                $this->hydrateFromCustomer($dataBag$customer),
                $context,
                false
            );

            $newsletterAccountPagelet->setSuccess(true);
            if ($newsletterAccountPagelet->isNewsletterDoi()) {
                $text = $this->translator->trans('newsletter.subscriptionPersistedSuccess');
            } else {
                $text = $this->translator->trans('newsletter.subscriptionConfirmationSuccess');
            }
            $newsletterAccountPagelet->setMessages(
                [
                    [
                        'type' => 'success',
                        'text' => $text,
                    ],
                ]
            );
Home | Imprint | This part of the site doesn't use cookies.