/** * @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; }
/** * Retrieve placeholder for title element and optionally set state * * @param string $title * @param string $setType * @return $this */ public function __invoke($title = null, $setType = null) { if (null !== $setType) { $setType = strtoupper($setType); } return parent::__invoke($title, $setType); }
/** * Turn helper into string * * @param string|null $indent * * @return string */ public function toString($indent = null) { $output = parent::toString($indent); $output = str_replace(['<title>', '</title>'], ['<h1>', '</h1>'], $output); if ($output == '<h1></h1>') { return ''; } return $output; }
/** * Render title string * * @return string */ public function renderTitle() { $output = parent::renderTitle(); if (isset($this->config['Site']['title'])) { $title = $this->config['Site']['title']; if ($this->autoEscape) { $title = $this->escape($title); } $output .= " | {$title}"; } return $output; }
/** * Turn helper into string * * @param string|null $indent * @return string */ public function toString($indent = null) { $output = parent::toString($indent); $output = str_replace(array('<title>', '</title>'), array('<h1>', '</h1>'), $output); return $output; }
/** * Retrieve placeholder for title element and optionally set state * * @param string $title * @param string $setType * * @return HeadTitle */ public function __invoke($title = null, $setType = null) { $this->setRcmSiteTitle(); $this->setRcmPageTitle(); return parent::__invoke($title, $setType); }
/** * @group ZF-10284 */ public function testReturnTypeDefaultAttachOrder() { $this->assertTrue($this->helper->setDefaultAttachOrder('PREPEND') instanceof Helper\HeadTitle); $this->assertEquals('PREPEND', $this->helper->getDefaultAttachOrder()); }