且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Zend Framework 2 中使用插件呈现自定义视图

更新时间:2023-11-17 20:54:52

只需使用您模块的 module.config.php 来指定您的电子邮件模板,例如:

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'
    )
),

之后你可以继续这部分 的文档.然后,您可以将视图模板从渲染器传递给 MimePart 将被 MimeMessage 使用,如

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));