/** * 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) { // See if we can determine the label for the current search type; first // check for an override in the GET parameters, then look at the incoming // params object.... $typeLabel = $request->get('typeLabel'); $type = $request->get('type'); if (empty($typeLabel) && !empty($type)) { $typeLabel = $params->getOptions()->getLabelForBasicHandler($type); } // Extract a search query: $lookfor = $request->get($this->requestParam); if (empty($lookfor) && is_object($params)) { $lookfor = $params->getQuery()->getAllTerms(); } // Set up the callback to initialize the parameters: $limit = $this->limit; $callback = function ($runner, $params) use($lookfor, $limit, $typeLabel) { $params->setLimit($limit); $params->setBasicSearch($lookfor, $params->getOptions()->getHandlerForLabel($typeLabel)); }; // Perform the search: $this->results = $this->runner->run([], $this->getSearchClassId(), $callback); }
/** * Constructor * * @param \VuFind\Search\Base\Params $params VuFind search results object. */ public function __construct(\VuFind\Search\Base\Params $params) { $this->params = $params; $this->options = $params->getOptions(); }