This method will apply cursor options present in the query structure
array. The Cursor may also be wrapped with an EagerCursor.
protected prepareCursor ( Doctrine\MongoDB\Cursor $cursor ) : Doctrine\MongoDB\CursorInterface | ||
$cursor | Doctrine\MongoDB\Cursor | |
return | Doctrine\MongoDB\CursorInterface |
/** * Prepare the Cursor returned by {@link Query::execute()}. * * This method will wrap the base Cursor with an ODM Cursor or EagerCursor, * and set the hydrate option and UnitOfWork hints. This occurs in addition * to any preparation done by the base Query class. * * @see \Doctrine\MongoDB\Cursor::prepareCursor() * @param BaseCursor $cursor * @return Cursor|EagerCursor */ protected function prepareCursor(BaseCursor $cursor) { $cursor = parent::prepareCursor($cursor); // Unwrap a base EagerCursor if ($cursor instanceof BaseEagerCursor) { $cursor = $cursor->getCursor(); } // Convert the base Cursor into an ODM Cursor $cursor = new Cursor($cursor, $this->dm->getUnitOfWork(), $this->class); // Wrap ODM Cursor with EagerCursor if (!empty($this->query['eagerCursor'])) { $cursor = new EagerCursor($cursor, $this->dm->getUnitOfWork(), $this->class); } $cursor->hydrate($this->hydrate); $cursor->setHints($this->unitOfWorkHints); return $cursor; }
/** * Prepare the Cursor returned by {@link Query::execute()}. * * This method will wrap the base Cursor with an ODM Cursor or EagerCursor, * and set the hydrate option and UnitOfWork hints. This occurs in addition * to any preparation done by the base Query class. * * @see \Doctrine\MongoDB\Cursor::prepareCursor() * @param BaseCursor $cursor * @return CursorInterface */ protected function prepareCursor(BaseCursor $cursor) { $cursor = parent::prepareCursor($cursor); // Convert the base Cursor into an ODM Cursor $cursorClass = !empty($this->query['eagerCursor']) ? 'Doctrine\\ODM\\MongoDB\\EagerCursor' : 'Doctrine\\ODM\\MongoDB\\Cursor'; $cursor = new $cursorClass($cursor, $this->dm->getUnitOfWork(), $this->class); $cursor->hydrate($this->hydrate); $cursor->setHints($this->unitOfWorkHints); if (!empty($this->primers)) { $referencePrimer = new ReferencePrimer($this->dm, $this->dm->getUnitOfWork()); $cursor->enableReferencePriming($this->primers, $referencePrimer); } return $cursor; }