コード例 #1
0
 /**
  * @test
  */
 public function setAttachmentsForStringSetsAttachments()
 {
     $this->fixture->setAttachments('Conceived at T3CON10');
     $this->assertSame('Conceived at T3CON10', $this->fixture->getAttachments());
 }
コード例 #2
0
 public function setNewsletter(Tx_Newsletter_Domain_Model_Newsletter $newsletter, $language = null)
 {
     $domain = $newsletter->getDomain();
     // When sending newsletter via scheduler (so via CLI mode) realurl cannot guess
     // the domain name by himself, so we help him by filling HTTP_HOST variable
     $_SERVER['HTTP_HOST'] = $domain;
     $_SERVER['SCRIPT_NAME'] = '/index.php';
     $this->siteUrl = "http://{$domain}/";
     $this->linksCache = array();
     $this->newsletter = $newsletter;
     $this->homeUrl = $this->siteUrl . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('newsletter');
     $this->senderName = $newsletter->getSenderName();
     $this->senderEmail = $newsletter->getSenderEmail();
     $bounceAccount = $newsletter->getBounceAccount();
     $this->bounceAddress = $bounceAccount ? $bounceAccount->getEmail() : '';
     // Build html
     $validatedContent = $newsletter->getValidatedContent($language);
     if (count($validatedContent['errors'])) {
         throw new Exception('The newsletter HTML content does not validate. The sending is aborted. See errors: ' . serialize($validatedContent['errors']));
     }
     $this->setHtml($validatedContent['content']);
     // Build title from HTML source (we cannot use $newsletter->getTitle(), because it is NOT localized)
     $this->setTitle($validatedContent['content']);
     // Attaching files
     $files = $newsletter->getAttachments();
     foreach ($files as $file) {
         if (trim($file) != '') {
             $filename = PATH_site . "uploads/tx_newsletter/{$file}";
             $this->attachments[] = Swift_Attachment::fromPath($filename);
         }
     }
 }