/** * @param Limit $limit * * @return WorkerData[] */ public function retrieve(Limit $limit) { $retrieveResult = new WorkerRetrieveResult(); $retrieveQuery = WorkerEntity::find(); $countQuery = $retrieveQuery->prepare(new Query()); $retrieveResult->totalItems = $countQuery->count(); $items = $retrieveQuery->limit($limit->getSize())->offset($limit->getOffset())->all(); $sensorVendorItems = []; foreach ($items as $item) { $sensorVendorItems[] = $this->mapper->entityToContract($item); } $retrieveResult->dataItems = $sensorVendorItems; return $retrieveResult; }
/** * @param Limit $limit * * @return ClientProxyDataRetrieveResult|Traversable */ public function getAll(Limit $limit) { $retrieveResult = new ClientProxyDataRetrieveResult(); $retrieveQuery = ClientProxyEntity::find(); $countQuery = $retrieveQuery->prepare(new Query()); $retrieveResult->totalItems = $countQuery->count(); $items = ClientProxyEntity::find()->with('endpoints')->limit($limit->getSize())->offset($limit->getOffset())->all(); $clientProxies = []; foreach ($items as $item) { $clientProxy = $this->_mapper->entityToContract($item); $endpointList = []; foreach ($item->endpoints as $endpointEntityItem) { $endpointList[] = $this->_endpointMapper->entityToContract($endpointEntityItem); } $clientProxy->endpointList = $endpointList; $clientProxies[] = $clientProxy; } $retrieveResult->dataItems = $clientProxies; return $retrieveResult; }