Example #1
0
 /**
  * Add the content to a given message.
  *
  * @param  \Illuminate\Mail\Message  $message
  * @param  string  $view
  * @param  string  $plain
  * @param  array   $data
  * @return void
  */
 protected function addContent($message, $view, $plain, $data)
 {
     if (isset($view)) {
         $viewContent = $this->getView($view, $data);
         $result = MailParser::parse($viewContent);
         $message->setBody($result['html'], 'text/html');
         if ($result['text']) {
             $message->addPart($result['text'], 'text/plain');
         }
         if ($subject = array_get($result['settings'], 'subject')) {
             $message->subject($subject);
         }
     }
     if (isset($plain)) {
         $message->addPart($this->getView($plain, $data), 'text/plain');
     }
 }
Example #2
0
 /**
  * Add the content to a given message.
  *
  * @param  \Illuminate\Mail\Message $message
  * @param  string $view
  * @param  string $plain
  * @param  array $data
  * @return void
  */
 protected function addContent($message, $view, $plain, $raw, $data)
 {
     /*
      * Extensibility
      */
     if ($this->fireEvent('mailer.beforeAddContent', [$message, $view, $data], true) === false || Event::fire('mailer.beforeAddContent', [$this, $message, $view, $data], true) === false) {
         return;
     }
     $html = null;
     $text = null;
     if (isset($view)) {
         $viewContent = $this->getView($view, $data);
         $result = MailParser::parse($viewContent);
         $html = $result['html'];
         if ($result['text']) {
             $text = $result['text'];
         }
         /*
          * Subject
          */
         $customSubject = $message->getSwiftMessage()->getSubject();
         if (empty($customSubject) && ($subject = array_get($result['settings'], 'subject'))) {
             $message->subject($subject);
         }
     }
     if (isset($plain)) {
         $text = $this->getView($plain, $data);
     }
     if (isset($raw)) {
         $text = $raw;
     }
     $this->addContentRaw($message, $html, $text);
     /*
      * Extensibility
      */
     $this->fireEvent('mailer.addContent', [$message, $view, $data]);
     Event::fire('mailer.addContent', [$this, $message, $view, $data]);
 }
Example #3
0
 protected static function getTemplateSections($code)
 {
     return MailParser::parse(File::get(View::make($code)->getPath()));
 }
Example #4
0
 /**
  * Add the content to a given message.
  *
  * @param  \Illuminate\Mail\Message $message
  * @param  string $view
  * @param  string $plain
  * @param  array $data
  * @return void
  */
 protected function addContent($message, $view, $plain, $raw, $data)
 {
     /*
      * Extensbility
      */
     if ($this->fireEvent('mailer.beforeAddContent', [$message, $view, $data], true) === false || Event::fire('mailer.beforeAddContent', [$this, $message, $view, $data], true) === false) {
         return;
     }
     if (isset($view)) {
         $viewContent = $this->getView($view, $data);
         $result = MailParser::parse($viewContent);
         $message->setBody($result['html'], 'text/html');
         if ($result['text']) {
             $message->addPart($result['text'], 'text/plain');
         }
         if ($subject = array_get($result['settings'], 'subject')) {
             $message->subject($subject);
         }
     }
     if (isset($plain)) {
         $message->addPart($this->getView($plain, $data), 'text/plain');
     }
     if (isset($raw)) {
         $message->addPart($raw, 'text/plain');
     }
     /*
      * Extensbility
      */
     $this->fireEvent('mailer.addContent', [$message, $view, $data]);
     Event::fire('mailer.addContent', [$this, $message, $view, $data]);
 }