0
我是ZF2的新手。经过几天试图找出所有这些东西应该如何工作,我无法弄清楚如何从服务调用TableGateway模型。Zend Framework 2调用TableGateway服务
所以我有控制器:
class SubscriberController extends AbstractActionController
{
/**
* @var \Subscriber\Service\SubscriberServiceInterface
*/
private $subscriberService;
/**
* @param $subscriberService
*/
public function __construct(SubscriberServiceInterface $subscriberService)
{
$this->subscriberService = $subscriberService;
}
Factroy此控制器:
class SubscriberControllerFactory implements FactoryInterface
{
/**
* Returns ArchiveController instance.
*
* @param ServiceLocatorInterface $serviceLocator
* @return SubscriberController
* @override
**/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$sm = $serviceLocator->getServiceLocator();
return new SubscriberController(
$sm->get('Subscriber\Service\SubscriberServiceInterface')
);
}
一些SubscriberTable:
class SubscriberTable
{
protected $tableGateway;
public function __construct(TableGateway $tableGateway)
{
$this->tableGateway = $tableGateway;
}
public function fetchAll()
{
$resultSet = $this->tableGateway->select();
return $resultSet;
}
和服务中,我想SubscriberTable实例,使一些逻辑。但我无法弄清楚如何在SubscriberService中调用此实例,并为SubscriberTable设置DbAdapter