lib/Doctrine/MongoDB/GridFS.php
private function withPrimaryReadPreference(\Closure $closure)
    {
        $prevReadPref = $this->mongoCollection->getReadPreference();
        $this->mongoCollection->setReadPreference(\MongoClient::RP_PRIMARY);

        try {
            return $closure();
        } finally {
            $prevTags = ! empty($prevReadPref['tagsets']) ? $prevReadPref['tagsets'] : [];
            $this->mongoCollection->setReadPreference($prevReadPref['type'], $prevTags);
        }
    }
private function withPrimaryReadPreference(\Closure $closure)
    {
        $prevReadPref = $this->mongoCollection->getReadPreference();
        $this->mongoCollection->setReadPreference(\MongoClient::RP_PRIMARY);

        try {
            return $closure();
        } finally {
            $prevTags = ! empty($prevReadPref['tagsets']) ? $prevReadPref['tagsets'] : [];
            $this->mongoCollection->setReadPreference($prevReadPref['type'], $prevTags);
        }
    }
private function withPrimaryReadPreference ( \ Closure $ closure ) { $ prevReadPref = $ this -> mongoCollection -> getReadPreference ( ) ; $ this -> mongoCollection -> setReadPreference ( \ MongoClient :: RP_PRIMARY ) ; try { return $ closure ( ) ; } finally { $ prevTags = ! empty ( $ prevReadPref [ 'tagsets' ] ) ? $ prevReadPref [ 'tagsets' ] : [ ] ; $ this -> mongoCollection -> setReadPreference ( $ prevReadPref [ 'type' ] , $ prevTags ) ; } }
Executes a closure with a temporary primary read preference.

@param \Closure $closure

@return mixed
Executes a closure with a temporary primary read preference .