2018-06-07 10:56:13 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class EmailRenderer
|
|
|
|
{
|
|
|
|
private $templateDir;
|
|
|
|
|
|
|
|
public $twig;
|
|
|
|
|
|
|
|
|
|
|
|
public $tmeplateList = [
|
|
|
|
|
|
|
|
"accountBillingInformation",
|
|
|
|
"accountCancellationNotice",
|
|
|
|
"accountInformationUpdated",
|
|
|
|
"accountInstallation",
|
|
|
|
"accountRefunded",
|
|
|
|
"accounSubscriptionPaymentFailed"
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$config = new Config();
|
2018-06-08 15:16:16 +00:00
|
|
|
$cConfigArray = $config->getConfig();
|
2018-06-07 10:56:13 +00:00
|
|
|
|
2018-06-08 15:16:16 +00:00
|
|
|
$loader = new Twig_Loader_Filesystem($cConfigArray['templates']['templatesDirectory']);
|
2018-06-07 10:56:13 +00:00
|
|
|
$this->twig = new Twig_Environment($loader);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderTemplate($Tmpl, Array $Data)
|
|
|
|
{
|
|
|
|
// $Data is an associative array of data
|
|
|
|
if(!in_array($this->templateList, $Tmpl))
|
|
|
|
{
|
|
|
|
throw new Exception("WARNING: Selected template not available");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return $this->twig->render($Tmpl, $Data);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|