/** * Handle a successful unsubscription by updating the local database. * * @param string $email Email address that was unsubscribed * @param string $mcListId Mailchimp list ID (remote) * @return void */ private function unsubscribe($email, $mcListId) { $method = 'findOneBy' . $this->emailUtil->getFieldNameUpperCamel(); $list = $this->mListRepo->findOneByMcListId($mcListId); $user = $this->feUserRepo->{$method}($email); if ($list && $user) { $list->removeFeUser($user); $this->mListRepo->update($list); $this->pm->persistAll(); } }
/** * Retrieve the email address from the given user. * * @param \TYPO3\CMS\Extbase\Domain\Model\FrontendUser $user * @return string */ private function getEmailFromUser(FrontendUser $user) { return $user->{'get' . $this->emailUtil->getFieldNameUpperCamel()}(); }