Esempio n. 1
0
 /**
  * @param Message $message
  * @return Message
  */
 public function render(Message $message)
 {
     $viewModel = new ViewModel($this->variables);
     $viewModel->setTemplate($this->template);
     $helperPluginManager = $this->renderer->getHelperPluginManager();
     /** @var HeadTitle $helper */
     $helper = $helperPluginManager->get('HeadTitle');
     // replace headTitle
     $headTitle = new HeadTitle();
     $headTitle->setAutoEscape(false);
     $helperPluginManager->setAllowOverride(true);
     $helperPluginManager->setService('HeadTitle', $headTitle);
     if (!$message->getBody()) {
         $message->setBody(new MimeMessage());
     }
     $text = new Part($this->renderer->render($viewModel));
     $text->charset = 'UTF-8';
     $text->boundary = $message->getBody()->getMime()->boundary();
     $text->encoding = Mime::ENCODING_BASE64;
     $text->type = Mime::TYPE_HTML;
     $message->getBody()->addPart($text);
     $message->setSubject($headTitle->renderTitle());
     // hack for ZF
     $message->setBody($message->getBody());
     // restore original helper
     $helperPluginManager->setService('HeadTitle', $helper);
     return $message;
 }
Esempio n. 2
0
 public function setUp()
 {
     Doctype::unsetDoctypeRegistry();
     $this->renderer = new PhpRenderer();
     $helpers = $this->renderer->getHelperPluginManager();
     $config = new HelperConfig();
     $config->configureServiceManager($helpers);
     $this->helper->setView($this->renderer);
 }