public function getRenderedContent() { $template = $this->getTemplate(); $subject = \Mailer\Render::instance()->resolve($template->event_subject); $html = \Mailer\Render::instance()->resolve($template->event_html); $text = \Mailer\Render::instance()->resolve($template->event_text); return ['subject' => $subject, 'body' => [$html, $text], 'fromEmail' => $template->from_email ? $template->from_email : null, 'fromName' => $template->from_name ? $template->from_name : null, 'cc' => $template->cc ? $template->cc : null, 'bcc' => $template->bcc ? $template->bcc : null, 'replyToName' => $template->replyto_name ? $template->replyto_name : null, 'replyToEmail' => $template->replyto_email ? $template->replyto_email : null]; }
public static function getEmailContents($eventName, $options = array()) { try { //fetch the event from mongo $event = (new \Mailer\Models\Events())->setCondition('event_name', $eventName)->getItem(); if (empty($event->id)) { throw new \Exception('Invalid Email Event'); } //if we have more than just an event name assign those variables to the view users the passed variable name; if (!empty($options)) { foreach ($options as $key => $value) { \Base::instance()->set($key, $value); } } $blocks = (new \Mailer\Models\Blocks())->getList(); //adding a base URL, you can be overriden with a block \Base::instance()->set('base_url', \Base::instance()->get('SCHEME') . '://' . \Base::instance()->get('HOST') . \Base::instance()->get('BASE')); foreach ($blocks as $block) { $html = \Mailer\Render::instance()->resolve($block->content); \Base::instance()->set($block->key, $html); } //get the email contents Subject and Content $content = $event->getRenderedContent(); //pass the additional $func = args; } catch (\Exception $e) { // TODO Log it? $content = null; } return $content; }