/** * {@inheritdoc} */ public function render() { $output = preg_match('/^<!DOCTYPE\\s.*>$/', trim($this->doctype->render())) ? trim($this->doctype->render()) . PHP_EOL : '<!DOCTYPE html>' . PHP_EOL; preg_match('/<html.*?>/', $this->html->render(), $result); $output .= isset($result[0]) ? $result[0] . PHP_EOL : '<html>' . PHP_EOL; $output .= substr($this->head->render(), 0, -7); $favicon = $this->favicon->render(); if (!empty($favicon)) { $output .= $favicon . PHP_EOL; } if ($this->styleSheet->length()) { $output .= $this->styleSheet->render('html') . PHP_EOL; } if ($this->javaScript->length()) { $tmp = call_user_func($this->scriptOutput, $this->javaScript, $this->translations); if (!empty($tmp)) { $output .= $tmp . PHP_EOL; } } if (!$this->script->isEmpty()) { $output .= '<script type="text/javascript">' . $this->script->render() . '</script>' . PHP_EOL; } $output .= $this->customHeadCode; $output .= '</head>' . PHP_EOL; $bodyEndPos = strrpos($this->body, "</body>"); if ($bodyEndPos !== false) { $output .= substr($this->body, 0, $bodyEndPos); $output .= $this->customBottomCode . '</body>'; } else { $output .= $this->body; } $output .= '</html>'; return $output; }