Exemplo n.º 1
0
 /**
  * {@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);
 }
Exemplo n.º 2
0
 /**
  * Set storage result
  *
  * @param StorageResultInterface $storageResult
  */
 protected function setStorageResult(StorageResultInterface $storageResult)
 {
     $this->storageResult = $storageResult;
     $this->items = [];
     $this->itemCount = $storageResult->count();
 }