From 3fff84d1fb4c1a4f81cd8c58ae90d4c856a759fc Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Wed, 17 Apr 2013 11:38:49 -0400 Subject: [PATCH] Updated similar items to use search service directly. --- module/VuFind/config/module.config.php | 4 ++-- module/VuFind/src/VuFind/Related/Similar.php | 16 ++++++++-------- .../src/VuFind/Related/WorldCatSimilar.php | 8 +++----- module/VuFind/src/VuFind/Search/Solr/Results.php | 15 --------------- 4 files changed, 13 insertions(+), 30 deletions(-) diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index c098ec11ace..c02c8688629 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -742,7 +742,7 @@ $config = array( }, 'similar' => function ($sm) { return new \VuFind\Related\Similar( - $sm->getServiceLocator()->get('VuFind\SearchResultsPluginManager') + $sm->getServiceLocator()->get('VuFind\Search') ); }, 'worldcateditions' => function ($sm) { @@ -753,7 +753,7 @@ $config = array( }, 'worldcatsimilar' => function ($sm) { return new \VuFind\Related\WorldCatSimilar( - $sm->getServiceLocator()->get('VuFind\SearchResultsPluginManager') + $sm->getServiceLocator()->get('VuFind\Search') ); }, ), diff --git a/module/VuFind/src/VuFind/Related/Similar.php b/module/VuFind/src/VuFind/Related/Similar.php index 6a119298765..a349633dae1 100644 --- a/module/VuFind/src/VuFind/Related/Similar.php +++ b/module/VuFind/src/VuFind/Related/Similar.php @@ -46,20 +46,20 @@ class Similar implements RelatedInterface protected $results; /** - * Results plugin manager + * Search service * - * @var \VuFind\Search\Results\PluginManager + * @var \VuFindSearch\Service */ - protected $resultsManager; + protected $searchService; /** * Constructor * - * @param \VuFind\Search\Results\PluginManager $results Results plugin manager + * @param \VuFindSearch\Service $results Results plugin manager */ - public function __construct(\VuFind\Search\Results\PluginManager $results) + public function __construct(\VuFindSearch\Service $search) { - $this->resultsManager = $results; + $this->searchService = $search; } /** @@ -74,8 +74,8 @@ class Similar implements RelatedInterface */ public function init($settings, $driver) { - $this->results = $this->resultsManager->get('Solr') - ->getSimilarRecords($driver->getUniqueId()); + $this->results + = $this->searchService->similar('Solr', $driver->getUniqueId()); } /** diff --git a/module/VuFind/src/VuFind/Related/WorldCatSimilar.php b/module/VuFind/src/VuFind/Related/WorldCatSimilar.php index 11fbe3e0efd..8579cd074d5 100644 --- a/module/VuFind/src/VuFind/Related/WorldCatSimilar.php +++ b/module/VuFind/src/VuFind/Related/WorldCatSimilar.php @@ -91,10 +91,8 @@ class WorldCatSimilar extends Similar } // Perform the search and save results: - $result = $this->resultsManager->get('WorldCat'); - $params = $result->getParams(); - $params->setLimit(5); - $params->setOverrideQuery($query); - $this->results = $result->getResults(); + $queryObj = new \VuFindSearch\Query\Query($query); + $result = $this->searchService->search('WorldCat', $queryObj, 0, 5); + $this->results = $result->getRecords(); } } diff --git a/module/VuFind/src/VuFind/Search/Solr/Results.php b/module/VuFind/src/VuFind/Search/Solr/Results.php index 712af62281c..1e7543d7c1a 100644 --- a/module/VuFind/src/VuFind/Search/Solr/Results.php +++ b/module/VuFind/src/VuFind/Search/Solr/Results.php @@ -408,21 +408,6 @@ class Results extends BaseResults return $list; } - /** - * Method to retrieve records similar to the provided ID. Returns an - * array of record driver objects. - * - * @param string $id Unique identifier of record - * - * @return array - * @tag NEW SEARCH - */ - public function getSimilarRecords($id) - { - $collection = $this->getSearchService()->similar($this->backendId, $id); - return $collection->getRecords(); - } - /** * Get complete facet counts for several index fields * -- GitLab