Skip to content
Snippets Groups Projects
Commit d5e37aa0 authored by Demian Katz's avatar Demian Katz
Browse files

Refactored for better granularity.

parent dcdfb092
Branches
Tags
No related merge requests found
......@@ -61,6 +61,19 @@ class HeadThemeResources extends \Zend\View\Helper\AbstractHelper
* @return void
*/
public function __invoke()
{
// Add various types of content to the header:
$this->addMetaTags();
$this->addLinks();
$this->addScripts();
}
/**
* Add meta tags to header.
*
* @return void
*/
protected function addMetaTags()
{
// Set up encoding:
$headMeta = $this->getView()->plugin('headmeta');
......@@ -73,7 +86,15 @@ class HeadThemeResources extends \Zend\View\Helper\AbstractHelper
if (!empty($generator)) {
$headMeta()->appendName('Generator', $generator);
}
}
/**
* Add links to header.
*
* @return void
*/
protected function addLinks()
{
// Convenient shortcut to view helper:
$headLink = $this->getView()->plugin('headlink');
......@@ -94,6 +115,24 @@ class HeadThemeResources extends \Zend\View\Helper\AbstractHelper
$headLink()->addLessStylesheet($current);
}
// If we have a favicon, load it now:
$favicon = $this->container->getFavicon();
if (!empty($favicon)) {
$imageLink = $this->getView()->plugin('imagelink');
$headLink(array(
'href' => $imageLink($favicon),
'type' => 'image/x-icon', 'rel' => 'shortcut icon'
));
}
}
/**
* Add scripts to header.
*
* @return void
*/
protected function addScripts()
{
// Load Javascript (same ordering considerations as CSS, above):
$headScript = $this->getView()->plugin('headscript');
foreach (array_reverse($this->container->getJs()) as $current) {
......@@ -105,15 +144,5 @@ class HeadThemeResources extends \Zend\View\Helper\AbstractHelper
? array('conditional' => trim($parts[1])) : array()
);
}
// If we have a favicon, load it now:
$favicon = $this->container->getFavicon();
if (!empty($favicon)) {
$imageLink = $this->getView()->plugin('imagelink');
$headLink(array(
'href' => $imageLink($favicon),
'type' => 'image/x-icon', 'rel' => 'shortcut icon'
));
}
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment