예제 #1
0
 /**
  * @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();
 }