From 9b51b7fe4fdaf874b082e68b917f0922a45f41b4 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Mon, 2 Jul 2012 14:19:57 -0400
Subject: [PATCH] Updated SortFacetList view helper.

---
 .../Theme/Root/Helper/SortFacetList.php       | 23 +++++++++++--------
 themes/root/theme.ini                         |  1 +
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/module/VuFind/src/VuFind/Theme/Root/Helper/SortFacetList.php b/module/VuFind/src/VuFind/Theme/Root/Helper/SortFacetList.php
index 808cd3d9d65..3fd15225911 100644
--- a/module/VuFind/src/VuFind/Theme/Root/Helper/SortFacetList.php
+++ b/module/VuFind/src/VuFind/Theme/Root/Helper/SortFacetList.php
@@ -26,6 +26,8 @@
  * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
  * @link     http://vufind.org/wiki/building_a_recommendations_module Wiki
  */
+namespace VuFind\Theme\Root\Helper;
+use Zend\View\Helper\AbstractHelper;
 
 /**
  * Sort facet list view helper
@@ -36,27 +38,28 @@
  * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
  * @link     http://vufind.org/wiki/building_a_recommendations_module Wiki
  */
-class VuFind_Theme_Root_Helper_SortFacetList extends Zend_View_Helper_Abstract
+class SortFacetList extends AbstractHelper
 {
     /**
      * Turns facet information into an alphabetical list.
      *
-     * @param VF_Search_Base_Results $results     Search result object
-     * @param string                 $field       Facet field to sort
-     * @param array                  $list        Facet value list extract from the
-     * search result object's getFacetList method
-     * @param array                  $urlSettings Options to use to generate search
-     * URLs for individual facet values
+     * @param \VuFind\Search\Base\Results $results     Search result object
+     * @param string                      $field       Facet field to sort
+     * @param array                       $list        Facet value list extract from
+     * the search result object's getFacetList method
+     * @param array                       $searchRoute Route to use to generate
+     * search URLs for individual facet values
      *
      * @return array      Associative URL => description array sorted by description
      */
-    public function sortFacetList($results, $field, $list, $urlSettings)
+    public function __invoke($results, $field, $list, $searchRoute)
     {
         $facets = array();
         $results->setLimit($results->getDefaultLimit());    // avoid limit on URL
+        $urlHelper = $this->getView()->plugin('url');
         foreach ($list as $value) {
-            $url = $this->view->url($urlSettings, 'default', true) .
-                $results->getUrl()->addFacet($field, $value['value']);
+            $url = $urlHelper($searchRoute)
+                . $results->getUrl()->addFacet($field, $value['value']);
             $facets[$url] = $value['displayText'];
         }
         natcasesort($facets);
diff --git a/themes/root/theme.ini b/themes/root/theme.ini
index 58af66c089b..dcd94e0bb2b 100644
--- a/themes/root/theme.ini
+++ b/themes/root/theme.ini
@@ -10,6 +10,7 @@ helpers_to_register[] = "ImageLink"
 helpers_to_register[] = "MobileUrl"
 helpers_to_register[] = "OfflineMode"
 helpers_to_register[] = "SearchOptions"
+helpers_to_register[] = "SortFacetList"
 helpers_to_register[] = "SystemEmail"
 helpers_to_register[] = "TransEsc"
 helpers_to_register[] = "Translate"
-- 
GitLab