protected function prepareCursor(Cursor $cursor)
{
/* Note: if this cursor resulted from a mapReduce command, applying the
* read preference may be undesirable. Results would have been written
* to the primary and replication may still be in progress.
*/
if (isset($this->query['readPreference'])) {
$cursor->setReadPreference($this->query['readPreference'], $this->query['readPreferenceTags']);
}
foreach ($this->getQueryOptions('hint', 'immortal', 'limit', 'maxTimeMS', 'skip', 'slaveOkay', 'sort') as $key => $value) {
$cursor->{$key}($value);
}
if (!empty($this->query['snapshot'])) {
$cursor->snapshot();
}
if (!empty($this->query['eagerCursor'])) {
$cursor = new EagerCursor($cursor);
}
if (isset($this->query['useIdentifierKeys'])) {
$cursor->setUseIdentifierKeys($this->query['useIdentifierKeys']);
}
return $cursor;
}