Example #1
0
 /**
  * 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 \CosmoW\Riak\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']) ? 'CosmoW\\ODM\\Riak\\EagerCursor' : 'CosmoW\\ODM\\Riak\\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;
 }