completeData example

if (isset($recipientId)) {
            /** @var NewsletterRecipientEntity $recipient */
            $recipient = $this->newsletterRecipientRepository->search(new Criteria([$recipientId])$context->getContext())->first();

            // If the user was previously subscribed but has unsubscribed now, the `getConfirmedAt()`             // will still be set. So we need to check for the status as well.             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();
        }

        
Home | Imprint | This part of the site doesn't use cookies.