/** * * @param \Zend\Db\TableGateway\AbstractTableGateway $data */ public function init($data) { if ($data instanceof \Zend\Db\TableGateway\AbstractTableGateway) { $this->tableGateway = $data; $this->table = $this->tableGateway->getTable(); $this->select = $data->getDefaultSql(); $this->setSourceObject($data); } else { throw new \InvalidArgumentException('A instance of Zend\\Db\\SqlSelect is needed to use this dataSource!'); } if ($this->getServiceLocator()->has('service_cache') && $this->getServiceLocator()->get('cache_metadata')['mode'] == 'enabled') { $this->setCache($this->getServiceLocator()->get('service_cache')); } return $this; }