Пример #1
0
 /**
  * Calculate the message body, given the HTML entered in the back-office, the message layout, and the message template
  * @param  ParserInterface $parser
  * @param $message
  * @param $layout
  * @param $template
  * @return bool
  */
 protected function getMessageBody($parser, $message, $layout, $template, $compressOutput = true)
 {
     $body = false;
     // Try to get the body from template file, if a file is defined
     if (!empty($template)) {
         try {
             $body = $parser->render($template, [], $compressOutput);
         } catch (ResourceNotFoundException $ex) {
             // Ignore this.
         }
     }
     // We did not get it ? Use the message entered in the back-office
     if ($body === false) {
         $body = $parser->renderString($message, [], $compressOutput);
     }
     // Do we have a layout ?
     if (!empty($layout)) {
         // Populate the message body variable
         $parser->assign('message_body', $body);
         // Render the layout file
         $body = $parser->render($layout, [], $compressOutput);
     }
     return $body;
 }