/** * @param bool $isTest * @param int $id * @param bool $dbResult * @param string $testEmailAddress * * @return array */ protected function sendTestNewsletter($isTest, $id, $dbResult, $testEmailAddress) { if ($isTest === true) { $bool2 = $this->newsletterHelpers->sendNewsletter($id, $testEmailAddress); $text = $this->translator->t('newsletter', 'create_success'); $result = $dbResult !== false && $bool2 !== false; } else { $text = $this->translator->t('newsletter', 'save_success'); $result = $dbResult !== false; } if ($result === false) { $text = $this->translator->t('newsletter', 'create_save_error'); } return [$text, $result]; }
/** * @param int $id * * @return \Symfony\Component\HttpFoundation\RedirectResponse * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException */ public function execute($id) { if ($this->newsletterRepository->newsletterExists($id) === true) { $accounts = $this->accountRepository->getAllActiveAccounts(); $cAccounts = count($accounts); $recipients = []; for ($i = 0; $i < $cAccounts; ++$i) { $recipients[] = $accounts[$i]['mail']; } $bool = $this->newsletterHelpers->sendNewsletter($id, $recipients); $bool2 = false; if ($bool === true) { $bool2 = $this->newsletterRepository->update(['status' => '1'], $id); } return $this->redirectMessages()->setMessage($bool === true && $bool2 !== false, $this->translator->t('newsletter', $bool === true && $bool2 !== false ? 'create_success' : 'create_save_error')); } throw new Core\Controller\Exception\ResultNotExistsException(); }