Doctrine\ODM\MongoDB\MongoDBException::documentNotMappedToCollection PHP Method

documentNotMappedToCollection() public static method

public static documentNotMappedToCollection ( string $className ) : MongoDBException
$className string
return MongoDBException
    public static function documentNotMappedToCollection($className)
    {
        return new self(sprintf('The "%s" document is not mapped to a MongoDB database collection.', $className));
    }

Usage Example

 /**
  * Returns the MongoCollection instance for a class.
  *
  * @param string $className The class name.
  * @return Doctrine\ODM\MongoDB\MongoCollection
  */
 public function getDocumentCollection($className)
 {
     $metadata = $this->_metadataFactory->getMetadataFor($className);
     $collection = $metadata->getCollection();
     $db = $metadata->getDB();
     $key = $db . '.' . $collection;
     if ($collection && !isset($this->_documentCollections[$key])) {
         if ($metadata->isFile()) {
             $collection = $this->getDocumentDB($className)->getGridFS($collection);
         } else {
             $collection = $this->getDocumentDB($className)->selectCollection($collection);
         }
         $mongoCollection = new MongoCollection($collection, $metadata, $this);
         $this->_documentCollections[$key] = $mongoCollection;
     }
     if (!isset($this->_documentCollections[$key])) {
         throw MongoDBException::documentNotMappedToCollection($className);
     }
     return $this->_documentCollections[$key];
 }
All Usage Examples Of Doctrine\ODM\MongoDB\MongoDBException::documentNotMappedToCollection