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

Eliminated need for ServiceLocatorAwareGateway.

...@@ -39,8 +39,10 @@ use VuFind\Date\Converter as DateConverter, ...@@ -39,8 +39,10 @@ use VuFind\Date\Converter as DateConverter,
* @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 Main Site * @link http://vufind.org Main Site
*/ */
class Resource extends ServiceLocatorAwareGateway class Resource extends RowGateway implements \VuFind\Db\Table\DbTableAwareInterface
{ {
use \VuFind\Db\Table\DbTableAwareTrait;
/** /**
* Constructor * Constructor
* *
......
<?php
/**
* Abstract base class for rows that need access to 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 Db_Row
* @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\Row;
use Zend\ServiceManager\ServiceLocatorAwareInterface,
Zend\ServiceManager\ServiceLocatorInterface;
/**
* Abstract base class for rows that need access to the service locator.
*
* @category VuFind2
* @package Db_Row
* @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
*/
class ServiceLocatorAwareGateway extends RowGateway
implements ServiceLocatorAwareInterface
{
use \Zend\ServiceManager\ServiceLocatorAwareTrait;
/**
* Get access to another table.
*
* @param string $table Table name
*
* @return \VuFind\Db\Table\Gateway
*/
public function getDbTable($table)
{
return $this->getServiceLocator()->get($table);
}
}
...@@ -37,8 +37,10 @@ use VuFind\Db\Table\Resource as ResourceTable, Zend\Db\Sql\Expression; ...@@ -37,8 +37,10 @@ use VuFind\Db\Table\Resource as ResourceTable, Zend\Db\Sql\Expression;
* @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 Main Site * @link http://vufind.org Main Site
*/ */
class Tags extends ServiceLocatorAwareGateway class Tags extends RowGateway implements \VuFind\Db\Table\DbTableAwareInterface
{ {
use \VuFind\Db\Table\DbTableAwareTrait;
/** /**
* Constructor * Constructor
* *
......
...@@ -42,8 +42,10 @@ use Zend\Db\Sql\Expression, ...@@ -42,8 +42,10 @@ use Zend\Db\Sql\Expression,
* @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 Main Site * @link http://vufind.org Main Site
*/ */
class User extends ServiceLocatorAwareGateway class User extends RowGateway implements \VuFind\Db\Table\DbTableAwareInterface
{ {
use \VuFind\Db\Table\DbTableAwareTrait;
/** /**
* Is encryption enabled? * Is encryption enabled?
* *
......
...@@ -39,8 +39,10 @@ use VuFind\Exception\ListPermission as ListPermissionException, ...@@ -39,8 +39,10 @@ use VuFind\Exception\ListPermission as ListPermissionException,
* @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 Main Site * @link http://vufind.org Main Site
*/ */
class UserList extends ServiceLocatorAwareGateway class UserList extends RowGateway implements \VuFind\Db\Table\DbTableAwareInterface
{ {
use \VuFind\Db\Table\DbTableAwareTrait;
/** /**
* Constructor * Constructor
* *
......
...@@ -70,4 +70,16 @@ trait DbTableAwareTrait ...@@ -70,4 +70,16 @@ trait DbTableAwareTrait
{ {
$this->tableManager = $manager; $this->tableManager = $manager;
} }
/**
* Get a database table object.
*
* @param string $table Table to load.
*
* @return Gateway
*/
public function getDbTable($table)
{
return $this->getDbTableManager()->get($table);
}
} }
\ No newline at end of file
...@@ -122,6 +122,9 @@ class Gateway extends AbstractTableGateway implements ServiceLocatorAwareInterfa ...@@ -122,6 +122,9 @@ class Gateway extends AbstractTableGateway implements ServiceLocatorAwareInterfa
if ($prototype instanceof ServiceLocatorAwareInterface) { if ($prototype instanceof ServiceLocatorAwareInterface) {
$prototype->setServiceLocator($this->getServiceLocator()); $prototype->setServiceLocator($this->getServiceLocator());
} }
\VuFind\ServiceManager\Initializer::initInstance(
$prototype, $this->getServiceLocator()->getServiceLocator()
);
return $prototype; return $prototype;
} }
......
...@@ -486,16 +486,4 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface, ...@@ -486,16 +486,4 @@ abstract class AbstractBase implements \VuFind\Db\Table\DbTableAwareInterface,
? call_user_func_array(array($this, $method), $params) ? call_user_func_array(array($this, $method), $params)
: null; : null;
} }
/**
* Get a database table object.
*
* @param string $table Table to load.
*
* @return \VuFind\Db\Table\User
*/
public function getDbTable($table)
{
return $this->getDbTableManager()->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