1
The examples I have seen使用Zend \ Authentication實例化一個指向數據庫的DbAdapter。但我想將它傳遞給我的表格網關模型。這是可能的還是我誤解了一些東西?zend 2:如何將Zend Authentication Adapter DbTable連接到Zend Db TableGateway TableGateway
我有這個安裝在我的Module.php:
'MyModule\Model\UserTable' => function($sm) {
$tableGateway = $sm->get('UserTableGateway');
$table = new UserTable($tableGateway);
return $table;
},
'UserTableGateway' => function($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(
new User());
return new TableGateway('view_users', $dbAdapter, null,
$resultSetPrototype);
},
),
現在在控制器動作,我想這樣做:
use Zend\Authentication\Adapter\DbTable as AuthAdapter;
...
$authAdapter = new AuthAdapter(**$this->getUserTable()->getAdapter()**);
$authAdapter
->setTableName('users')
->setIdentityColumn('username')
->setCredentialColumn('password')
如何集成我TableGateway使用Zend \ Authentication的模型?