Я пытаюсь создать экземпляр Zend\Db\TableGateway
, но просто не могу понять это правильно. Это то, что у меня в module.php
:Создание экземпляра Zend Db TableGateway с помощью диспетчера служб
use Question\Model\QuestionsTable;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
//other statements and then getServiceConfig()
public function getServiceConfig()
{
return array(
'factories' => array(
'Question\Model\QuestionsTable' => function($sm) {
$tableGateway = $sm->get('AlbumTableGateway');
$table = new QuestionsTable($tableGateway);
return $table;
},
'AlbumTableGateway' => function ($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new QuestionsTable());
return new TableGateway('questions', $dbAdapter, null, $resultSetPrototype);
},
),
);
}
Это мой QuestionsTable.php
файл:
namespace Question\Model;
use Zend\Db\TableGateway\TableGateway;
class QuestionsTable
{
public $usr_id;
public $title;
public $description;
public $status;
protected $tableGateway;
public function __construct(TableGateway $tableGateway)
{
$this->tableGateway = $tableGateway;
}
}
И это ошибка я получаю: Catchable fatal error: Argument 1 passed to Question\Model\QuestionsTable::__construct() must be an instance of Zend\Db\TableGateway\TableGateway,none given.
Спасибо заранее.
любой Zend Dev, пожалуйста, просветите свет на этом ... потому что я думаю, что все в порядке с моей стороны. – Joss