diff --git a/module/VuFind/src/VuFind/Autocomplete/Solr.php b/module/VuFind/src/VuFind/Autocomplete/Solr.php index cc989178fbf8e83ce6a3d81f5ae7b6290345f5eb..026e3f3661c436a7c734e09fc3847afa7023ac17 100644 --- a/module/VuFind/src/VuFind/Autocomplete/Solr.php +++ b/module/VuFind/src/VuFind/Autocomplete/Solr.php @@ -27,6 +27,8 @@ * @link http://vufind.org/wiki/autocomplete Wiki */ namespace VuFind\Autocomplete; +use Zend\ServiceManager\ServiceLocatorAwareInterface, + Zend\ServiceManager\ServiceLocatorInterface; /** * Solr Autocomplete Module @@ -39,13 +41,14 @@ namespace VuFind\Autocomplete; * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/autocomplete Wiki */ -class Solr implements AutocompleteInterface +class Solr implements AutocompleteInterface, ServiceLocatorAwareInterface { protected $handler; protected $displayField; protected $defaultDisplayField = 'title'; protected $sortField; protected $filters; + protected $searchClassId = 'Solr'; protected $searchObject; @@ -91,10 +94,15 @@ class Solr implements AutocompleteInterface */ protected function initSearchObject() { + // Get the search manager: + $sm = $this->getServiceLocator()->getServiceLocator()->get('SearchManager'); + $sm->setSearchClassId($this->searchClassId); + // Build a new search object: - $params = new \VuFind\Search\Solr\Params(); - $this->searchObject = new \VuFind\Search\Solr\Results($params); - $this->searchObject->getOptions()->spellcheckEnabled(false); + $params = $sm->getParams(); + $params->getOptions()->spellcheckEnabled(false); + $params->recommendationsEnabled(false); + $this->searchObject = $sm->getResults($params); } /** @@ -279,4 +287,26 @@ class Solr implements AutocompleteInterface return true; } + /** + * Set the service locator. + * + * @param ServiceLocatorInterface $serviceLocator Locator to register + * + * @return Manager + */ + public function setServiceLocator(ServiceLocatorInterface $serviceLocator) + { + $this->serviceLocator = $serviceLocator; + return $this; + } + + /** + * Get the service locator. + * + * @return \Zend\ServiceManager\ServiceLocatorInterface + */ + public function getServiceLocator() + { + return $this->serviceLocator; + } } diff --git a/module/VuFind/src/VuFind/Autocomplete/SolrAuth.php b/module/VuFind/src/VuFind/Autocomplete/SolrAuth.php index daa42eb352b79cb1818aa790d53afe73463a110f..b8efbcda43d4bb682d7fd9038d8538ce87281724 100644 --- a/module/VuFind/src/VuFind/Autocomplete/SolrAuth.php +++ b/module/VuFind/src/VuFind/Autocomplete/SolrAuth.php @@ -47,19 +47,6 @@ class SolrAuth extends Solr public function __construct() { $this->defaultDisplayField = 'heading'; - } - - /** - * initSearchObject - * - * Initialize the search object used for finding recommendations. - * - * @return void - */ - protected function initSearchObject() - { - // Build a new search object: - $params = new \VuFind\Search\SolrAuth\Params(); - $this->searchObject = new \VuFind\Search\SolrAuth\Results($params); + $this->searchClassId = 'SolrAuth'; } } diff --git a/module/VuFind/src/VuFind/Autocomplete/SolrReserves.php b/module/VuFind/src/VuFind/Autocomplete/SolrReserves.php index e6a91ec5a2cc6d715b353a3f29bc7ef01bf6c920..73851191d250d3103cda8bb505dfa37d793766e0 100644 --- a/module/VuFind/src/VuFind/Autocomplete/SolrReserves.php +++ b/module/VuFind/src/VuFind/Autocomplete/SolrReserves.php @@ -47,20 +47,6 @@ class SolrReserves extends Solr public function __construct() { $this->defaultDisplayField = 'course'; - } - - /** - * initSearchObject - * - * Initialize the search object used for finding recommendations. - * - * @return void - */ - protected function initSearchObject() - { - // Build a new search object: - $params = new \VuFind\Search\SolrReserves\Params(); - $this->searchObject = new \VuFind\Search\SolrReserves\Results($params); - $this->searchObject->getOptions()->spellcheckEnabled(false); + $this->searchClassId = 'SolrReserves'; } }