/** * @param DibiConnection * @param IRepository */ public function __construct(DibiConnection $connection, IRepository $repository) { $this->repository = $repository; $this->connection = $connection; $this->mapper = $repository->getMapper(); $this->conventional = $this->mapper->getConventional(); }
/** * Returns entry from specific position. * @param int * @return IEntity|NULL */ public function get($position) { if (isset($this->cachedResult[$position])) { $entity = $this->cachedResult[$position]; if ($entity === false) { return NULL; } return $entity; } if ($this->currentPosition !== $position) { if ($this->resultSeek($position)) { $this->currentPosition = $position; } else { $this->currentPosition = -1; $this->cachedResult[$position] = false; return NULL; } } $row = $this->resultFetch(); if ($row === false) { $this->currentPosition = -1; $this->cachedResult[$position] = false; return NULL; } else { $this->currentPosition++; $entity = $this->repository->hydrateEntity($row); $this->cachedResult[$position] = $entity; return $entity; } }
/** @return IEntity */ public function current() { return $this->repository->hydrateEntity(parent::current()); }
/** @return IRepositoryContainer */ public final function getModel() { return $this->repository->getModel(); }