我在视图中有一个电子邮件模板,我想编写一个ConsoleApplication进程,准备发送电子邮件.因为它是ConsoleApplication我无法访问控制器.是否可以呈现视图?
Sam*_*ark 17
这是我使用的:
private function render($template, array $data = array()){
$path = Yii::getPathOfAlias('application.views.email').'/'.$template.'.php';
if(!file_exists($path)) throw new Exception('Template '.$path.' does not exist.');
return $this->renderFile($path, $data, true);
}
Run Code Online (Sandbox Code Playgroud)
它从电子邮件模板的意见/电子邮件.