lib/Doctrine/ODM/MongoDB/DocumentManager.php
public function getDocumentCollection($className)
    {
        $className = ltrim($className, '\\');

        $metadata = $this->metadataFactory->getMetadataFor($className);
        $collectionName = $metadata->getCollection();

        if ( ! $collectionName) {
            throw MongoDBException::documentNotMappedToCollection($className);
        }

        if ( ! isset($this->documentCollections[$className])) {
            $db = $this->getDocumentDatabase($className);

            $this->documentCollections[$className] = $metadata->isFile()
                ? $db->getGridFS($collectionName)
                : $db->selectCollection($collectionName);
        }

        $collection = $this->documentCollections[$className];

        if ($metadata->slaveOkay !== null) {
            $collection->setSlaveOkay($metadata->slaveOkay);
        }

        return $this->documentCollections[$className];
    }
public function getDocumentCollection($className)
    {
        $className = ltrim($className, '\\');

        $metadata = $this->metadataFactory->getMetadataFor($className);
        $collectionName = $metadata->getCollection();

        if ( ! $collectionName) {
            throw MongoDBException::documentNotMappedToCollection($className);
        }

        if ( ! isset($this->documentCollections[$className])) {
            $db = $this->getDocumentDatabase($className);

            $this->documentCollections[$className] = $metadata->isFile()
                ? $db->getGridFS($collectionName)
                : $db->selectCollection($collectionName);
        }

        $collection = $this->documentCollections[$className];

        if ($metadata->slaveOkay !== null) {
            $collection->setSlaveOkay($metadata->slaveOkay);
        }

        return $this->documentCollections[$className];
    }
public function getDocumentCollection ( $ className ) { $ className = ltrim ( $ className , '\\' ) ; $ metadata = $ this -> metadataFactory -> getMetadataFor ( $ className ) ; $ collectionName = $ metadata -> getCollection ( ) ; if ( ! $ collectionName ) { throw MongoDBException :: documentNotMappedToCollection ( $ className ) ; } if ( ! isset ( $ this -> documentCollections [ $ className ] ) ) { $ db = $ this -> getDocumentDatabase ( $ className ) ; $ this -> documentCollections [ $ className ] = $ metadata -> isFile ( ) ? $ db -> getGridFS ( $ collectionName ) : $ db -> selectCollection ( $ collectionName ) ; } $ collection = $ this -> documentCollections [ $ className ] ; if ( $ metadata -> slaveOkay !== null ) { $ collection -> setSlaveOkay ( $ metadata -> slaveOkay ) ; } return $ this -> documentCollections [ $ className ] ; }
Returns the MongoCollection instance for a class.

@param string $className The class name.
@throws MongoDBException When the $className param is not mapped to a collection
@return \Doctrine\MongoDB\Collection
Returns the MongoCollection instance for a class .