/** * {@inheritDoc} * @see \Fixin\Model\Entity\Cache\CacheInterface::fetchResultEntity($storageResult) */ public function fetchResultEntity(StorageResultInterface $storageResult) : EntityInterface { $data = $storageResult->current(); $storageResult->next(); $entityId = $this->repository->createId(array_intersect_key($data, $this->primaryKeyFlipped)); $key = (string) $entityId; if (isset($this->entities[$key])) { return $this->entities[$key]; } if (isset($this->invalidEntities[$key])) { $entity = $this->invalidEntities[$key]; unset($this->invalidEntities[$key]); return $this->entities[$key] = $entity->exchangeArray($data); } return $this->entities[$key] = $this->entityPrototype->withOptions([EntityInterface::OPTION_ENTITY_ID => $entityId])->exchangeArray($data); }
/** * Set storage result * * @param StorageResultInterface $storageResult */ protected function setStorageResult(StorageResultInterface $storageResult) { $this->storageResult = $storageResult; $this->items = []; $this->itemCount = $storageResult->count(); }