diff --git a/module/VuFind/src/VuFind/Theme/Root/Helper/AbstractServiceLocator.php b/module/VuFind/src/VuFind/Theme/Root/Helper/AbstractServiceLocator.php new file mode 100644 index 0000000000000000000000000000000000000000..b651cd5657e05c66d8025b62dd5300bf67a6a02f --- /dev/null +++ b/module/VuFind/src/VuFind/Theme/Root/Helper/AbstractServiceLocator.php @@ -0,0 +1,71 @@ +<?php +/** + * Base class for helpers that pull resources from the service locator. + * + * 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/building_a_recommendations_module Wiki + */ +namespace VuFind\Theme\Root\Helper; +use Zend\ServiceManager\ServiceLocatorInterface, + Zend\ServiceManager\ServiceLocatorAwareInterface, + Zend\View\Helper\AbstractHelper; + +/** + * Base class for helpers that pull resources from the service locator. + * + * @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/building_a_recommendations_module Wiki + */ +abstract class AbstractServiceLocator extends AbstractHelper + implements ServiceLocatorAwareInterface +{ + protected $serviceLocator; + + /** + * Set the service locator. + * + * @param ServiceLocatorInterface $serviceLocator Locator to register + * + * @return Manager + */ + public function setServiceLocator(ServiceLocatorInterface $serviceLocator) + { + // The service locator passed in here is a Zend\View\HelperPluginManager; + // we want to pull out the main Zend\ServiceManager\ServiceManager. + $this->serviceLocator = $serviceLocator->getServiceLocator(); + return $this; + } + + /** + * Get the service locator. + * + * @return \Zend\ServiceManager\ServiceLocatorInterface + */ + public function getServiceLocator() + { + return $this->serviceLocator; + } +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Theme/Root/Helper/Cart.php b/module/VuFind/src/VuFind/Theme/Root/Helper/Cart.php index bffdbd03cfaf91d1ffb261b4f3e018ff1d36e50b..4fb2081cd2c2252e6b3e571060acad9a5fd4fb22 100644 --- a/module/VuFind/src/VuFind/Theme/Root/Helper/Cart.php +++ b/module/VuFind/src/VuFind/Theme/Root/Helper/Cart.php @@ -26,9 +26,6 @@ * @link http://vufind.org/wiki/building_a_recommendations_module Wiki */ namespace VuFind\Theme\Root\Helper; -use Zend\ServiceManager\ServiceLocatorInterface, - Zend\ServiceManager\ServiceLocatorAwareInterface, - Zend\View\Helper\AbstractHelper; /** * Cart view helper @@ -39,10 +36,8 @@ use Zend\ServiceManager\ServiceLocatorInterface, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/building_a_recommendations_module Wiki */ -class Cart extends AbstractHelper implements ServiceLocatorAwareInterface +class Cart extends AbstractServiceLocator { - protected $serviceLocator; - /** * Get the Cart object from the service manager. * @@ -52,29 +47,4 @@ class Cart extends AbstractHelper implements ServiceLocatorAwareInterface { return $this->getServiceLocator()->get('Cart'); } - - /** - * Set the service locator. - * - * @param ServiceLocatorInterface $serviceLocator Locator to register - * - * @return Manager - */ - public function setServiceLocator(ServiceLocatorInterface $serviceLocator) - { - // The service locator passed in here is a Zend\View\HelperPluginManager; - // we want to pull out the main Zend\ServiceManager\ServiceManager. - $this->serviceLocator = $serviceLocator->getServiceLocator(); - return $this; - } - - /** - * Get the service locator. - * - * @return \Zend\ServiceManager\ServiceLocatorInterface - */ - public function getServiceLocator() - { - return $this->serviceLocator; - } } \ No newline at end of file