From f3f1ee58d4e22bd0c7449b70301fc94048953313 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Fri, 7 Sep 2012 07:27:28 -0400
Subject: [PATCH] Use search manager in Summon controller.

---
 .../src/VuFind/Controller/SummonController.php | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/module/VuFind/src/VuFind/Controller/SummonController.php b/module/VuFind/src/VuFind/Controller/SummonController.php
index 7799067ed87..4a3de1e7c91 100644
--- a/module/VuFind/src/VuFind/Controller/SummonController.php
+++ b/module/VuFind/src/VuFind/Controller/SummonController.php
@@ -26,9 +26,7 @@
  * @link     http://vufind.org   Main Site
  */
 namespace VuFind\Controller;
-use VuFind\Cache\Manager as CacheManager,
-    VuFind\Search\Summon\Params as SummonParams,
-    VuFind\Search\Summon\Results as SummonResults, Zend\Mvc\MvcEvent;
+use VuFind\Cache\Manager as CacheManager, Zend\Mvc\MvcEvent;
 
 /**
  * Summon Controller
@@ -122,24 +120,32 @@ class SummonController extends AbstractSearch
      * data may come from the cache, and it is currently shared between the Home
      * page and the Advanced search screen.
      *
-     * @return SummonResults
+     * @return \VuFind\Search\Summon\Results
      */
     protected function getAdvancedFacets()
     {
         // Check if we have facet results cached, and build them if we don't.
         $cache = CacheManager::getInstance()->getCache('object');
         if (!($results = $cache->getItem('summonSearchHomeFacets'))) {
-            $params = new SummonParams();
+            $sm = $this->getSearchManager()->setSearchClassId('Summon');
+            $params = $sm->getParams();
             $params->addFacet('Language,or,1,20');
             $params->addFacet('ContentType,or,1,20', 'Format');
 
             // We only care about facet lists, so don't get any results:
             $params->setLimit(0);
 
-            $results = new SummonResults($params);
+            $results = $sm->getResults($params);
             $results->getResults();                     // force processing for cache
+
+            // Temporarily remove the service manager so we can cache the
+            // results (otherwise we'll get errors about serializing closures):
+            $results->unsetServiceLocator();
             $cache->setItem('summonSearchHomeFacets', $results);
         }
+
+        // Restore the real service locator to the object:
+        $results->restoreServiceLocator($this->getServiceLocator());
         return $results;
     }
 
-- 
GitLab