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

Decoupled record drivers from service locator.

parent f22bd1f0
No related merge requests found
...@@ -27,9 +27,7 @@ ...@@ -27,9 +27,7 @@
*/ */
namespace VuFind\RecordDriver; namespace VuFind\RecordDriver;
use VuFind\Exception\LoginRequired as LoginRequiredException, use VuFind\Exception\LoginRequired as LoginRequiredException,
VuFind\Tags, VuFind\XSLT\Import\VuFind as ArticleStripper, VuFind\Tags, VuFind\XSLT\Import\VuFind as ArticleStripper;
Zend\ServiceManager\ServiceLocatorInterface,
Zend\ServiceManager\ServiceLocatorAwareInterface;
/** /**
* Abstract base record model. * Abstract base record model.
...@@ -42,7 +40,7 @@ use VuFind\Exception\LoginRequired as LoginRequiredException, ...@@ -42,7 +40,7 @@ use VuFind\Exception\LoginRequired as LoginRequiredException,
* @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://www.vufind.org Main Page * @link http://www.vufind.org Main Page
*/ */
abstract class AbstractBase implements ServiceLocatorAwareInterface, abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface,
\VuFind\I18n\Translator\TranslatorAwareInterface, \VuFind\I18n\Translator\TranslatorAwareInterface,
\VuFindSearch\Response\RecordInterface \VuFindSearch\Response\RecordInterface
{ {
...@@ -82,11 +80,11 @@ abstract class AbstractBase implements ServiceLocatorAwareInterface, ...@@ -82,11 +80,11 @@ abstract class AbstractBase implements ServiceLocatorAwareInterface,
protected $fields = array(); 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) * Translator (or null if unavailable)
...@@ -473,39 +471,41 @@ abstract class AbstractBase implements ServiceLocatorAwareInterface, ...@@ -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->getDbTableManager()->get($table);
return $this;
} }
/** /**
* 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() $this->tableManager = $manager;
->get('VuFind\DbTablePluginManager')->get($table);
} }
/** /**
......
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