Skip to content

Instantly share code, notes, and snippets.

@linxlad
Created January 24, 2015 12:40
Show Gist options
  • Save linxlad/1d3ea0d09688024d7f97 to your computer and use it in GitHub Desktop.
Save linxlad/1d3ea0d09688024d7f97 to your computer and use it in GitHub Desktop.
/**
* Load a template from the system
*
* @param string $name The email template to use
* @param array $params Parameters to replace in the message
*
* @return mixed
*/
private function getTemplate($name, $params)
{
$dispatcher = $this->getDI()->get('dispatcher');
$viewPath = APP_DIR.'modules/'.$dispatcher->getModuleName().'/views/';
// Merge some bases into the parameters, these will
// always be available.
$params = array_merge(['baseUri' => $this->config->application->baseUri], $params);
// Load up a view handler and feed it the things we need
$view = new View\Simple();
$view->setViewsDir($viewPath);
$view->setVars($params);
// Load up the layout
$layout = new View\Simple();
$layout->setViewsDir($viewPath);
$layout->setVar('content', $view->render('email/'.$name));
// and finally return the contents
return $layout->render('layouts/email');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment