コード例 #1
0
ファイル: MailTest.php プロジェクト: GerDner/luck-docker
 /**
  * @covers \Shopware\Models\Mail\Mail::arrayGetPath
  */
 public function testArrayGetPath()
 {
     $input = array('sShop' => 'Shopware', 'sConfig' => array('lang' => array('iso' => 'de', 'id' => 5), 'sMail' => '*****@*****.**'));
     $exceptedOutput = array('sShop' => 'Shopware', 'sConfig.lang.iso' => 'de', 'sConfig.lang.id' => 5, 'sConfig.sMail' => '*****@*****.**');
     $mail = new Mail();
     $this->assertEquals($mail->arrayGetPath($input), $exceptedOutput);
 }
コード例 #2
0
 /**
  * Loads values from MailModel into Mail
  *
  * @param \Enlight_Components_Mail $mail
  * @param \Shopware\Models\Mail\Mail $mailModel
  * @param array $overrideConfig
  * @return \Enlight_Components_Mail
  * @throws \Enlight_Exception
  */
 public function loadValues(\Enlight_Components_Mail $mail, \Shopware\Models\Mail\Mail $mailModel, $overrideConfig = array())
 {
     $stringCompiler = $this->getStringCompiler();
     $subject = $stringCompiler->compileString($mailModel->getSubject());
     if (!empty($subject)) {
         $mail->setSubject($subject);
     }
     if (!empty($overrideConfig["fromMail"])) {
         $fromMail = $overrideConfig["fromMail"];
     } else {
         $fromMail = $stringCompiler->compileString($mailModel->getFromMail());
     }
     if (!empty($overrideConfig["fromName"])) {
         $fromName = $overrideConfig["fromName"];
     } else {
         $fromName = $stringCompiler->compileString($mailModel->getFromName());
     }
     if (!empty($fromMail) && !empty($fromName)) {
         $mail->setFrom($fromMail, $fromName);
     } elseif (!empty($fromMail)) {
         $mail->setFrom($fromMail);
     }
     $bodyText = $stringCompiler->compileString($mailModel->getContent());
     $mail->setBodyText($bodyText);
     if ($mailModel->isHtml()) {
         $mail->setBodyHtml($stringCompiler->compileString($mailModel->getContentHtml()));
     }
     /** @var $attachment \Shopware\Models\Mail\Attachment */
     foreach ($mailModel->getAttachments() as $attachment) {
         if ($attachment->getShopId() !== null && ($this->getShop() === null || $attachment->getShopId() != $this->getShop()->getId())) {
             continue;
         }
         if (false === ($fileHandle = fopen($attachment->getPath(), 'r'))) {
             throw new \Enlight_Exception('Could not load file: ' . $attachment->getPath());
         }
         $fileAttachment = $mail->createAttachment($fileHandle);
         $fileAttachment->filename = $attachment->getFileName();
     }
     return $mail;
 }
コード例 #3
0
ファイル: TemplateMail.php プロジェクト: GerDner/luck-docker
 /**
  * Loads values from MailModel into Mail
  *
  * @param \Enlight_Components_Mail $mail
  * @param \Shopware\Models\Mail\Mail $mailModel
  * @param array $overrideConfig
  * @return \Enlight_Components_Mail
  * @throws \Enlight_Exception
  */
 public function loadValues(\Enlight_Components_Mail $mail, \Shopware\Models\Mail\Mail $mailModel, $overrideConfig = array())
 {
     $stringCompiler = $this->getStringCompiler();
     $subject = $stringCompiler->compileString($mailModel->getSubject());
     if (!empty($subject)) {
         $mail->setSubject($subject);
     }
     if (!empty($overrideConfig["fromMail"])) {
         $fromMail = $overrideConfig["fromMail"];
     } else {
         $fromMail = $stringCompiler->compileString($mailModel->getFromMail());
     }
     if (!empty($overrideConfig["fromName"])) {
         $fromName = $overrideConfig["fromName"];
     } else {
         $fromName = $stringCompiler->compileString($mailModel->getFromName());
     }
     if (!empty($fromMail) && !empty($fromName)) {
         $mail->setFrom($fromMail, $fromName);
     } elseif (!empty($fromMail)) {
         $mail->setFrom($fromMail);
     }
     $bodyText = $stringCompiler->compileString($mailModel->getContent());
     $mail->setBodyText($bodyText);
     if ($mailModel->isHtml()) {
         $mail->setBodyHtml($stringCompiler->compileString($mailModel->getContentHtml()));
     }
     /** @var $attachment \Shopware\Models\Mail\Attachment */
     foreach ($mailModel->getAttachments() as $attachment) {
         if ($attachment->getShopId() !== null && ($this->getShop() === null || $attachment->getShopId() != $this->getShop()->getId())) {
             continue;
         }
         $mediaService = Shopware()->Container()->get('shopware_media.media_service');
         if (!$mediaService->has($attachment->getPath())) {
             Shopware()->Container()->get('corelogger')->error('Could not load file: ' . $attachment->getPath());
         } else {
             $fileAttachment = $mail->createAttachment($mediaService->read($attachment->getPath()));
             $fileAttachment->filename = $attachment->getFileName();
         }
     }
     return $mail;
 }
コード例 #4
0
ファイル: Mail.php プロジェクト: GerDner/luck-docker
 /**
  * Creates new mail
  */
 public function createMailAction()
 {
     $params = $this->Request()->getParams();
     $mail = new Mail();
     $params['attribute'] = $params['attribute'][0];
     $params['dirty'] = 1;
     $mail->fromArray($params);
     try {
         Shopware()->Models()->persist($mail);
         Shopware()->Models()->flush();
     } catch (Exception $e) {
         $this->View()->assign(array('success' => false, 'message' => $e->getMessage()));
         return;
     }
     $data = $this->getMail($mail->getId());
     $data = $data['data'];
     $this->View()->assign(array('success' => true, 'data' => $data));
 }