Skip to content
This repository has been archived by the owner on Nov 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #92 from doctrine/read-pref-methods
Browse files Browse the repository at this point in the history
CollectionTest refactoring and get/setReadPreference() methods
  • Loading branch information
jmikola committed Mar 4, 2013
2 parents ec10f4d + 257fb45 commit bc59129
Show file tree
Hide file tree
Showing 9 changed files with 446 additions and 252 deletions.
14 changes: 14 additions & 0 deletions lib/Doctrine/MongoDB/Collection.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -666,6 +666,20 @@ public function getSlaveOkay()
return \MongoClient::RP_PRIMARY !== $readPref['type']; return \MongoClient::RP_PRIMARY !== $readPref['type'];
} }


public function getReadPreference()
{
return $this->getMongoCollection()->getReadPreference();
}

public function setReadPreference($readPreference, array $tags = null)
{
if (isset($tags)) {
return $this->getMongoCollection()->setReadPreference($readPreference, $tags);
}

return $this->getMongoCollection()->setReadPreference($readPreference);
}

public function validate($scanData = false) public function validate($scanData = false)
{ {
return $this->getMongoCollection()->validate($scanData); return $this->getMongoCollection()->validate($scanData);
Expand Down
14 changes: 14 additions & 0 deletions lib/Doctrine/MongoDB/Connection.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -258,6 +258,20 @@ public function selectDatabase($name)
return $database; return $database;
} }


public function getReadPreference()
{
return $this->mongo->getReadPreference();
}

public function setReadPreference($readPreference, array $tags = null)
{
if (isset($tags)) {
return $this->mongo->setReadPreference($readPreference, $tags);
}

return $this->mongo->setReadPreference($readPreference);
}

/** /**
* Method which creates a Doctrine\MongoDB\Database instance. * Method which creates a Doctrine\MongoDB\Database instance.
* *
Expand Down
14 changes: 14 additions & 0 deletions lib/Doctrine/MongoDB/Cursor.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -387,6 +387,20 @@ public function getSingleResult()
return $result; return $result;
} }


public function getReadPreference()
{
return $this->getMongoDB()->getReadPreference();
}

public function setReadPreference($readPreference, array $tags = null)
{
if (isset($tags)) {
return $this->mongoCursor->setReadPreference($readPreference, $tags);
}

return $this->mongoCursor->setReadPreference($readPreference);
}

protected function retry(\Closure $retry, $recreate = false) protected function retry(\Closure $retry, $recreate = false)
{ {
if ($this->numRetries) { if ($this->numRetries) {
Expand Down
14 changes: 14 additions & 0 deletions lib/Doctrine/MongoDB/Database.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -250,6 +250,20 @@ public function getSlaveOkay()
return \MongoClient::RP_PRIMARY !== $readPref['type']; return \MongoClient::RP_PRIMARY !== $readPref['type'];
} }


public function getReadPreference()
{
return $this->getMongoDB()->getReadPreference();
}

public function setReadPreference($readPreference, array $tags = null)
{
if (isset($tags)) {
return $this->getMongoDB()->setReadPreference($readPreference, $tags);
}

return $this->getMongoDB()->setReadPreference($readPreference);
}

public function getProfilingLevel() public function getProfilingLevel()
{ {
return $this->getMongoDB()->getProfilingLevel(); return $this->getMongoDB()->getProfilingLevel();
Expand Down
Loading

0 comments on commit bc59129

Please sign in to comment.