diff --git a/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php b/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php index 57b364cf39db775a099512715790b0d95a4bd768..c325e73d72cd9ae0e3618c64582f6f5c5b52a647 100644 --- a/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php +++ b/module/VuFind/src/VuFind/RecordDriver/AbstractBase.php @@ -27,9 +27,7 @@ */ namespace VuFind\RecordDriver; use VuFind\Exception\LoginRequired as LoginRequiredException, - VuFind\Tags, VuFind\XSLT\Import\VuFind as ArticleStripper, - Zend\ServiceManager\ServiceLocatorInterface, - Zend\ServiceManager\ServiceLocatorAwareInterface; + VuFind\Tags, VuFind\XSLT\Import\VuFind as ArticleStripper; /** * Abstract base record model. @@ -42,7 +40,7 @@ use VuFind\Exception\LoginRequired as LoginRequiredException, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://www.vufind.org Main Page */ -abstract class AbstractBase implements ServiceLocatorAwareInterface, +abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface, \VuFind\I18n\Translator\TranslatorAwareInterface, \VuFindSearch\Response\RecordInterface { @@ -82,11 +80,11 @@ abstract class AbstractBase implements ServiceLocatorAwareInterface, protected $fields = array(); /** - * Service locator + * Database table plugin manager * - * @var ServiceLocatorInterface + * @var \VuFind\Db\Table\PluginManager */ - protected $serviceLocator; + protected $tableManager; /** * Translator (or null if unavailable) @@ -473,39 +471,41 @@ abstract class AbstractBase implements ServiceLocatorAwareInterface, } /** - * Set the service locator. + * Get a database table object. * - * @param ServiceLocatorInterface $serviceLocator Locator to register + * @param string $table Table to load. * - * @return AbstractBase + * @return \VuFind\Db\Table\User */ - public function setServiceLocator(ServiceLocatorInterface $serviceLocator) + public function getDbTable($table) { - $this->serviceLocator = $serviceLocator; - return $this; + return $this->getDbTableManager()->get($table); } /** - * Get the service locator. + * Get the table plugin manager. Throw an exception if it is missing. * - * @return \Zend\ServiceManager\ServiceLocatorInterface + * @throws \Exception + * @return \VuFind\Db\Table\PluginManager */ - public function getServiceLocator() + public function getDbTableManager() { - return $this->serviceLocator; + if (null === $this->tableManager) { + throw new \Exception('DB table manager missing.'); + } + return $this->tableManager; } /** - * Get a database table object. + * Set the table plugin manager. * - * @param string $table Name of table to retrieve + * @param \VuFind\Db\Table\PluginManager $manager Plugin manager * - * @return \VuFind\Db\Table\Gateway + * @return void */ - protected function getDbTable($table) + public function setDbTableManager(\VuFind\Db\Table\PluginManager $manager) { - return $this->getServiceLocator()->getServiceLocator() - ->get('VuFind\DbTablePluginManager')->get($table); + $this->tableManager = $manager; } /**