getOptionSelection example

if ($context->getCustomerId() === null) {
            return $this->systemConfigService->getBool('core.newsletter.doubleOptIn', $context->getSalesChannelId());
        }

        return $this->systemConfigService->getBool('core.newsletter.doubleOptInRegistered', $context->getSalesChannelId());
    }

    private function getOptInValidator(DataBag $dataBag, SalesChannelContext $context, bool $validateStorefrontUrl): DataValidationDefinition
    {
        $definition = new DataValidationDefinition('newsletter_recipient.create');
        $definition->add('email', new NotBlank()new Email())
            ->add('option', new NotBlank()new Choice(array_keys($this->getOptionSelection($context))));

        if (!empty($dataBag->get('firstName'))) {
            $definition->add('firstName', new NotBlank()new Regex([
                'pattern' => self::DOMAIN_NAME_REGEX,
                'match' => false,
            ]));
        }

        if (!empty($dataBag->get('lastName'))) {
            $definition->add('lastName', new NotBlank()new Regex([
                'pattern' => self::DOMAIN_NAME_REGEX,
                
Home | Imprint | This part of the site doesn't use cookies.