/** * @param Form $form */ private function logInvalidSubscription($form) { $error = 'Could not synchronize user ' . $form->getField('EMAIL')->getValue() . ":\n"; /** @var Field $field */ foreach ($form->getFields(TRUE) as $field) { foreach ($field->getErrors() as $error) { $error .= $field->getName() . ': ' . $this->translate($error) . "\n"; } } GeneralUtility::sysLog($error, 't3chimp', 2); }
/** * @param Form $form * @return int the performed action */ public function saveForm(Form $form) { if ($form->getField('FORM_ACTION')->getValue() == 'subscribe') { list($fieldValues, $selectedGroupings, $emailFormat) = $this->separateForm($form); try { $this->addSubscriber($form->getListId(), $fieldValues, $selectedGroupings, $this->settingsProvider->get('doubleOptIn'), $emailFormat, !$this->settingsProvider->get('disableWelcomeEmail')); $action = self::ACTION_SUBSCRIBE; } catch (MailChimpApi\ListAlreadySubscribed $ex) { $this->updateSubscriber($form->getListId(), $fieldValues, $selectedGroupings, $emailFormat); $action = self::ACTION_UPDATE; } } else { $this->removeSubscriber($form->getListId(), $form->getField('EMAIL')->getApiValue()); $action = self::ACTION_UNSUBSCRIBE; } return $action; }