The Gitlab instance will be restarted on Monday April 28th at 2AM. There will be a short interruption of service.

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

Created DbTableAwareTrait.

parent ca30902e
No related merge requests found
......@@ -43,6 +43,7 @@ use Zend\Log\LoggerInterface;
abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface,
\VuFind\I18n\Translator\TranslatorAwareInterface, \Zend\Log\LoggerAwareInterface
{
use \VuFind\Db\Table\DbTableAwareTrait;
use \VuFind\I18n\Translator\TranslatorAwareTrait;
/**
......@@ -59,13 +60,6 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface,
*/
protected $config = null;
/**
* Database table plugin manager
*
* @var \VuFind\Db\Table\PluginManager
*/
protected $tableManager;
/**
* Logger (or false for none)
*
......@@ -312,32 +306,6 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface,
return $this->getDbTableManager()->get('User');
}
/**
* Get the table plugin manager. Throw an exception if it is missing.
*
* @throws \Exception
* @return \VuFind\Db\Table\PluginManager
*/
public function getDbTableManager()
{
if (null === $this->tableManager) {
throw new \Exception('DB table manager missing.');
}
return $this->tableManager;
}
/**
* Set the table plugin manager.
*
* @param \VuFind\Db\Table\PluginManager $manager Plugin manager
*
* @return void
*/
public function setDbTableManager(\VuFind\Db\Table\PluginManager $manager)
{
$this->tableManager = $manager;
}
/**
* Verify that a password fulfills the password policy. Throws exception if
* the password is invalid.
......
......@@ -40,12 +40,7 @@ namespace VuFind\Autocomplete;
*/
class Tag implements AutocompleteInterface, \VuFind\Db\Table\DbTableAwareInterface
{
/**
* Database table plugin manager
*
* @var \VuFind\Db\Table\PluginManager
*/
protected $tableManager;
use \VuFind\Db\Table\DbTableAwareTrait;
/**
* getSuggestions
......@@ -94,30 +89,4 @@ class Tag implements AutocompleteInterface, \VuFind\Db\Table\DbTableAwareInterfa
{
return $this->getDbTableManager()->get('Tags');
}
/**
* Get the table plugin manager. Throw an exception if it is missing.
*
* @throws \Exception
* @return \VuFind\Db\Table\PluginManager
*/
public function getDbTableManager()
{
if (null === $this->tableManager) {
throw new \Exception('DB table manager missing.');
}
return $this->tableManager;
}
/**
* Set the table plugin manager.
*
* @param \VuFind\Db\Table\PluginManager $manager Plugin manager
*
* @return void
*/
public function setDbTableManager(\VuFind\Db\Table\PluginManager $manager)
{
$this->tableManager = $manager;
}
}
<?php
/**
* Default implementation of DbTableAwareInterface.
*
* PHP version 5
*
* Copyright (C) Villanova University 2015.
*
* 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 Db_Table
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org Main Site
*/
namespace VuFind\Db\Table;
/**
* Default implementation of DbTableAwareInterface.
*
* @category VuFind2
* @package Db_Table
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org Main Site
*/
trait DbTableAwareTrait
{
/**
* Database table plugin manager
*
* @var \VuFind\Db\Table\PluginManager
*/
protected $tableManager;
/**
* Get the table plugin manager. Throw an exception if it is missing.
*
* @throws \Exception
* @return \VuFind\Db\Table\PluginManager
*/
public function getDbTableManager()
{
if (null === $this->tableManager) {
throw new \Exception('DB table manager missing.');
}
return $this->tableManager;
}
/**
* Set the table plugin manager.
*
* @param \VuFind\Db\Table\PluginManager $manager Plugin manager
*
* @return void
*/
public function setDbTableManager(\VuFind\Db\Table\PluginManager $manager)
{
$this->tableManager = $manager;
}
}
\ No newline at end of file
......@@ -44,6 +44,7 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface,
\VuFind\I18n\Translator\TranslatorAwareInterface,
\VuFindSearch\Response\RecordInterface
{
use \VuFind\Db\Table\DbTableAwareTrait;
use \VuFind\I18n\Translator\TranslatorAwareTrait;
/**
......@@ -81,13 +82,6 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface,
*/
protected $fields = array();
/**
* Database table plugin manager
*
* @var \VuFind\Db\Table\PluginManager
*/
protected $tableManager;
/**
* Constructor
*
......@@ -504,30 +498,4 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface,
{
return $this->getDbTableManager()->get($table);
}
/**
* Get the table plugin manager. Throw an exception if it is missing.
*
* @throws \Exception
* @return \VuFind\Db\Table\PluginManager
*/
public function getDbTableManager()
{
if (null === $this->tableManager) {
throw new \Exception('DB table manager missing.');
}
return $this->tableManager;
}
/**
* Set the table plugin manager.
*
* @param \VuFind\Db\Table\PluginManager $manager Plugin manager
*
* @return void
*/
public function setDbTableManager(\VuFind\Db\Table\PluginManager $manager)
{
$this->tableManager = $manager;
}
}
......@@ -40,6 +40,8 @@ use Zend\Session\SaveHandler\SaveHandlerInterface;
abstract class AbstractBase implements SaveHandlerInterface,
\VuFind\Db\Table\DbTableAwareInterface
{
use \VuFind\Db\Table\DbTableAwareTrait;
/**
* Session lifetime in seconds
*
......@@ -54,13 +56,6 @@ abstract class AbstractBase implements SaveHandlerInterface,
*/
protected $config = null;
/**
* Database table plugin manager
*
* @var \VuFind\Db\Table\PluginManager
*/
protected $tableManager;
/**
* Set configuration.
*
......@@ -145,32 +140,6 @@ abstract class AbstractBase implements SaveHandlerInterface,
// Something to keep in mind though.
}
/**
* Get the table plugin manager. Throw an exception if it is missing.
*
* @throws \Exception
* @return \VuFind\Db\Table\PluginManager
*/
public function getDbTableManager()
{
if (null === $this->tableManager) {
throw new \Exception('DB table manager missing.');
}
return $this->tableManager;
}
/**
* Set the table plugin manager.
*
* @param \VuFind\Db\Table\PluginManager $manager Plugin manager
*
* @return void
*/
public function setDbTableManager(\VuFind\Db\Table\PluginManager $manager)
{
$this->tableManager = $manager;
}
/**
* Get a database table object.
*
......
......@@ -38,12 +38,7 @@ namespace VuFind\Statistics\Driver;
*/
class Db extends AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface
{
/**
* Database table plugin manager
*
* @var \VuFind\Db\Table\PluginManager
*/
protected $tableManager;
use \VuFind\Db\Table\DbTableAwareTrait;
/**
* Write a message to the log.
......@@ -94,32 +89,6 @@ class Db extends AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface
return $userStats->getBrowserStats($version, $limit);
}
/**
* Get the table plugin manager. Throw an exception if it is missing.
*
* @throws \Exception
* @return \VuFind\Db\Table\PluginManager
*/
public function getDbTableManager()
{
if (null === $this->tableManager) {
throw new \Exception('DB table manager missing.');
}
return $this->tableManager;
}
/**
* Set the table plugin manager.
*
* @param \VuFind\Db\Table\PluginManager $manager Plugin manager
*
* @return void
*/
public function setDbTableManager(\VuFind\Db\Table\PluginManager $manager)
{
$this->tableManager = $manager;
}
/**
* Get a database table object.
*
......
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