Skip to content
Snippets Groups Projects
Commit a5b9abca authored by Demian Katz's avatar Demian Katz
Browse files

Refactored SpellingSuggestions to use AbstractResultsPassthrough.

- This new abstract base class makes it easy to create modules that only need to display a template based on the results object.
parent 222984cc
Branches
Tags
No related merge requests found
<?php
/**
* Simple abstract recommendation module that simply passes the Results object
* through to the template.
*
* PHP version 5
*
* Copyright (C) Villanova University 2017.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category VuFind
* @package Recommendations
* @author Demian Katz <demian.katz@villanova.edu>
* @author Chris Hallberg <challber@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:recommendation_modules Wiki
*/
namespace VuFind\Recommend;
/**
* Simple abstract recommendation module that simply passes the Results object
* through to the template.
*
* @category VuFind
* @package Recommendations
* @author Demian Katz <demian.katz@villanova.edu>
* @author Chris Hallberg <challber@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:recommendation_modules Wiki
*/
class AbstractResultsPassthrough implements RecommendInterface
{
/**
* Search results object.
*
* @var \VuFind\Search\Base\Results
*/
protected $results;
/**
* Store the configuration of the recommendation module.
*
* @param string $settings Settings from searches.ini.
*
* @return void
*/
public function setConfig($settings)
{
// No settings used by default.
}
/**
* Called at the end of the Search Params objects' initFromRequest() method.
* This method is responsible for setting search parameters needed by the
* recommendation module and for reading any existing search parameters that may
* be needed.
*
* @param \VuFind\Search\Base\Params $params Search parameter object
* @param \Zend\StdLib\Parameters $request Parameter object representing user
* request.
*
* @return void
*/
public function init($params, $request)
{
// No initialization required by default.
}
/**
* Called after the Search Results object has performed its main search. This
* may be used to extract necessary information from the Search Results object
* or to perform completely unrelated processing.
*
* @param \VuFind\Search\Base\Results $results Search results object
*
* @return void
*/
public function process($results)
{
$this->results = $results;
}
/**
* Get results stored in the object.
*
* @return \VuFind\Search\Base\Results
*/
public function getResults()
{
return $this->results;
}
}
...@@ -38,64 +38,6 @@ namespace VuFind\Recommend; ...@@ -38,64 +38,6 @@ namespace VuFind\Recommend;
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:recommendation_modules Wiki * @link https://vufind.org/wiki/development:plugins:recommendation_modules Wiki
*/ */
class SpellingSuggestions implements RecommendInterface class SpellingSuggestions extends AbstractResultsPassthrough
{ {
/**
* Search results object.
*
* @var \VuFind\Search\Base\Results
*/
protected $results;
/**
* Store the configuration of the recommendation module.
*
* @param string $settings Settings from searches.ini.
*
* @return void
*/
public function setConfig($settings)
{
// No settings used at present.
}
/**
* Called at the end of the Search Params objects' initFromRequest() method.
* This method is responsible for setting search parameters needed by the
* recommendation module and for reading any existing search parameters that may
* be needed.
*
* @param \VuFind\Search\Base\Params $params Search parameter object
* @param \Zend\StdLib\Parameters $request Parameter object representing user
* request.
*
* @return void
*/
public function init($params, $request)
{
}
/**
* Called after the Search Results object has performed its main search. This
* may be used to extract necessary information from the Search Results object
* or to perform completely unrelated processing.
*
* @param \VuFind\Search\Base\Results $results Search results object
*
* @return void
*/
public function process($results)
{
$this->results = $results;
}
/**
* Get results stored in the object.
*
* @return \VuFind\Search\Base\Results
*/
public function getResults()
{
return $this->results;
}
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment