Ejemplo n.º 1
0
 /**
  * @test
  */
 public function getIsTestReturnsInitialValueForBoolean()
 {
     $this->assertSame(false, $this->subject->getIsTest());
     $this->assertSame(false, $this->subject->isIsTest());
 }
Ejemplo n.º 2
0
 /**
  * Creates a new Newsletter and forwards to the list action.
  *
  * @param \Ecodev\Newsletter\Domain\Model\Newsletter $newNewsletter a fresh Newsletter object which has not yet been added to the repository
  * @dontverifyrequesthash
  * @dontvalidate $newNewsletter
  * @ignorevalidation $newNewsletter
  */
 public function createAction(Newsletter $newNewsletter = null)
 {
     $limitTestRecipientCount = 10;
     // This is a low limit, technically, but it does not make sense to test a newsletter for more people than that anyway
     $recipientList = $newNewsletter->getRecipientList();
     $recipientList->init();
     $count = $recipientList->getCount();
     $validatedContent = $newNewsletter->getValidatedContent($language);
     // If we attempt to create a newsletter as a test but it has too many recipient, reject it (we cannot safely send several emails wihtout slowing down respoonse and/or timeout issues)
     if ($newNewsletter->getIsTest() && $count > $limitTestRecipientCount) {
         $this->addFlashMessage($this->translate('flashmessage_test_maximum_recipients', [$count, $limitTestRecipientCount]), $this->translate('flashmessage_test_maximum_recipients_title'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
         $this->view->assign('success', false);
     } elseif (count($validatedContent['errors'])) {
         $this->addFlashMessage('The newsletter HTML content does not validate. See tab "Newsletter > Status" for details.', $this->translate('flashmessage_newsletter_invalid'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
         $this->view->assign('success', false);
     } else {
         // If it's a test newsletter, it's planned to be sent right now
         if ($newNewsletter->getIsTest()) {
             $newNewsletter->setPlannedTime(new DateTime());
         }
         // Save the new newsletter
         $this->newsletterRepository->add($newNewsletter);
         $this->persistenceManager->persistAll();
         $this->view->assign('success', true);
         // If it is test newsletter, send it immediately
         if ($newNewsletter->getIsTest()) {
             try {
                 // Fill the spool and run the queue
                 Tools::createSpool($newNewsletter);
                 Tools::runSpool($newNewsletter);
                 $this->addFlashMessage($this->translate('flashmessage_test_newsletter_sent'), $this->translate('flashmessage_test_newsletter_sent_title'), \TYPO3\CMS\Core\Messaging\FlashMessage::OK);
             } catch (\Exception $exception) {
                 $this->addFlashMessage($exception->getMessage(), $this->translate('flashmessage_test_newsletter_error'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
             }
         } else {
             $this->addFlashMessage($this->translate('flashmessage_newsletter_queued'), $this->translate('flashmessage_newsletter_queued_title'), \TYPO3\CMS\Core\Messaging\FlashMessage::OK);
         }
     }
     $this->view->setVariablesToRender(['data', 'success', 'flashMessages']);
     $this->view->setConfiguration(['data' => self::resolveJsonViewConfiguration()]);
     $this->view->assign('data', $newNewsletter);
     $this->flushFlashMessages();
 }