How to Render a custom view with plugins in Zend Framework 2

别等时光非礼了梦想. 提交于 2019-12-05 11:01:44

Just use the module.config.php of your module to specify your email template, like:

'view_manager' => array(
    'template_path_stack' => array(
        'user' => __DIR__ . '/../view'
    ),
    'template_map' => array(
        'email/view' => __DIR__ . '/../view/application/email/view.phtml'
    )
),

After which you can go on with this part of the documentation. You can then pass your view template from the renderer to the MimePart which will be used by the MimeMessage like

$viewModel = new \Zend\View\Model\ViewModel();
$viewModel->setTemplate('email/view');

$renderer = $this->serviceLocator->get('Zend\View\Renderer\RendererInterface');
$htmlPart = new \Zend\Mime\Part($renderer->render($viewModel));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!