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

Created abstract base class for Cart helper so we can create other service...

Created abstract base class for Cart helper so we can create other service locator based view helpers.
parent 009f3d09
No related merge requests found
<?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
...@@ -26,9 +26,6 @@ ...@@ -26,9 +26,6 @@
* @link http://vufind.org/wiki/building_a_recommendations_module Wiki * @link http://vufind.org/wiki/building_a_recommendations_module Wiki
*/ */
namespace VuFind\Theme\Root\Helper; namespace VuFind\Theme\Root\Helper;
use Zend\ServiceManager\ServiceLocatorInterface,
Zend\ServiceManager\ServiceLocatorAwareInterface,
Zend\View\Helper\AbstractHelper;
/** /**
* Cart view helper * Cart view helper
...@@ -39,10 +36,8 @@ use Zend\ServiceManager\ServiceLocatorInterface, ...@@ -39,10 +36,8 @@ use Zend\ServiceManager\ServiceLocatorInterface,
* @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 http://vufind.org/wiki/building_a_recommendations_module Wiki * @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. * Get the Cart object from the service manager.
* *
...@@ -52,29 +47,4 @@ class Cart extends AbstractHelper implements ServiceLocatorAwareInterface ...@@ -52,29 +47,4 @@ class Cart extends AbstractHelper implements ServiceLocatorAwareInterface
{ {
return $this->getServiceLocator()->get('Cart'); 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
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