Je suis nouveau à ZF2. Après quelques jours d'essayer de comprendre comment tout cela devrait fonctionner, je n'ai pas réussi à comprendre comment appeler TableGateway Model from Service.Zend Framework 2 appel TableGateway en service
J'ai donc contrôleur:
class SubscriberController extends AbstractActionController
{
/**
* @var \Subscriber\Service\SubscriberServiceInterface
*/
private $subscriberService;
/**
* @param $subscriberService
*/
public function __construct(SubscriberServiceInterface $subscriberService)
{
$this->subscriberService = $subscriberService;
}
Factroy pour ce contrôleur:
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')
);
}
Certains SubscriberTable:
class SubscriberTable
{
protected $tableGateway;
public function __construct(TableGateway $tableGateway)
{
$this->tableGateway = $tableGateway;
}
public function fetchAll()
{
$resultSet = $this->tableGateway->select();
return $resultSet;
}
et service dans lequel je veux exemple SubscriberTable et faire une certaine logique. Mais je ne peux pas comprendre comment dois-je appeler cette instance dans SubscriberService et définir le dbAdapter pour SubscriberTable