From 8c536f3c8e85c31320c9253f7b9b1e384b1ae198 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Fri, 28 Feb 2014 12:24:21 -0500 Subject: [PATCH] Added SearchParams helper. --- .../src/VuFind/View/Helper/Root/Factory.php | 14 ++++ .../VuFind/View/Helper/Root/SearchParams.php | 70 +++++++++++++++++++ themes/root/theme.config.php | 1 + 3 files changed, 85 insertions(+) create mode 100644 module/VuFind/src/VuFind/View/Helper/Root/SearchParams.php diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Factory.php b/module/VuFind/src/VuFind/View/Helper/Root/Factory.php index 676edbc1d06..1336e5d0ec6 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Factory.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Factory.php @@ -381,6 +381,20 @@ class Factory ); } + /** + * Construct the SearchParams helper. + * + * @param ServiceManager $sm Service manager. + * + * @return SearchParams + */ + public static function getSearchParams(ServiceManager $sm) + { + return new SearchParams( + $sm->getServiceLocator()->get('VuFind\SearchParamsPluginManager') + ); + } + /** * Construct the SearchTabs helper. * diff --git a/module/VuFind/src/VuFind/View/Helper/Root/SearchParams.php b/module/VuFind/src/VuFind/View/Helper/Root/SearchParams.php new file mode 100644 index 00000000000..e0545980882 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/SearchParams.php @@ -0,0 +1,70 @@ +<?php +/** + * "Retrieve search params" view helper + * + * PHP version 5 + * + * Copyright (C) Villanova University 2010. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package View_Helpers + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/vufind2:developer_manual Wiki + */ +namespace VuFind\View\Helper\Root; +use VuFind\Search\Params\PluginManager; + +/** + * "Retrieve search params" view helper + * + * @category VuFind2 + * @package View_Helpers + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/vufind2:developer_manual Wiki + */ +class SearchParams extends \Zend\View\Helper\AbstractHelper +{ + /** + * Search manager + * + * @var PluginManager + */ + protected $manager; + + /** + * Constructor + * + * @param PluginManager $manager Search manager + */ + public function __construct(PluginManager $manager) + { + $this->manager = $manager; + } + + /** + * Wrapper to the options plugin manager + * + * @param string $type The search type of the object to retrieve + * + * @return \VuFind\Search\Base\Options + */ + public function __invoke($type = 'Solr') + { + return $this->manager->get($type); + } +} \ No newline at end of file diff --git a/themes/root/theme.config.php b/themes/root/theme.config.php index fc46a3eac55..895f82339ee 100644 --- a/themes/root/theme.config.php +++ b/themes/root/theme.config.php @@ -28,6 +28,7 @@ return array( 'reviews' => array('VuFind\View\Helper\Root\Factory', 'getReviews'), 'searchbox' => array('VuFind\View\Helper\Root\Factory', 'getSearchBox'), 'searchoptions' => array('VuFind\View\Helper\Root\Factory', 'getSearchOptions'), + 'searchparams' => array('VuFind\View\Helper\Root\Factory', 'getSearchParams'), 'searchtabs' => array('VuFind\View\Helper\Root\Factory', 'getSearchTabs'), 'syndeticsplus' => array('VuFind\View\Helper\Root\Factory', 'getSyndeticsPlus'), 'systememail' => array('VuFind\View\Helper\Root\Factory', 'getSystemEmail'), -- GitLab