public function testFavicon()
 {
     $favicon = new FaviconElement();
     $favicon->setBasePath('/path/to/favicon/');
     $favicon->setTileColor('#000000');
     $favicon->setFaviconTemplate('{{basepath}} {{tileColor}} {{basepath}} {{tileColor}}');
     $this->assertEquals($favicon->render(), '/path/to/favicon/ #000000 /path/to/favicon/ #000000');
     $favicon->enable(false);
     $this->assertEquals($favicon->render(), '');
     $favicon->enable(true);
     $favicon->setFaviconTemplate('<link rel="apple-touch-icon" sizes="57x57" href="{{basepath}}/apple-touch-icon-57x57.png"><meta name="msapplication-TileColor" content="{{tileColor}}">');
     $this->assertEquals($favicon->render(), '<link rel="apple-touch-icon" sizes="57x57" href="/path/to/favicon//apple-touch-icon-57x57.png"><meta name="msapplication-TileColor" content="#000000">');
 }
Example #2
0
 /**
  * {@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;
 }