From d5e37aa0811e861913436cf9373bb70680f99e66 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Tue, 16 Dec 2014 13:06:23 -0500
Subject: [PATCH] Refactored for better granularity.

---
 .../View/Helper/HeadThemeResources.php        | 49 +++++++++++++++----
 1 file changed, 39 insertions(+), 10 deletions(-)

diff --git a/module/VuFindTheme/src/VuFindTheme/View/Helper/HeadThemeResources.php b/module/VuFindTheme/src/VuFindTheme/View/Helper/HeadThemeResources.php
index e38fc81a35f..82b648f79ec 100644
--- a/module/VuFindTheme/src/VuFindTheme/View/Helper/HeadThemeResources.php
+++ b/module/VuFindTheme/src/VuFindTheme/View/Helper/HeadThemeResources.php
@@ -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'
-            ));
-        }
     }
 }
-- 
GitLab