public static function MongoCollectionFactory::createFromDatabase in MongoDB 8
Return value
static
2 calls to MongoCollectionFactory::createFromDatabase()
- MongoCollectionFactory::create in src/
MongoCollectionFactory.php - Factory method for this class.
- settings.php in drivers/
lib/ Drupal/ Driver/ Database/ mongodb/ Install/ settings.php
File
- src/
MongoCollectionFactory.php, line 84 - Definition of Drupal\mongodb\MongodbBundle.
Class
- MongoCollectionFactory
- Creates mongo collections based on settings.
Namespace
Drupal\mongodbCode
public static function createFromDatabase() {
$db_info = Database::getConnectionInfo()['default'];
if ($db_info['driver'] == 'mongodb') {
$mongo['servers']['default']['server'] = $db_info['database'];
return new static($mongo);
}
throw new \Exception("Can't initialize mongo.");
}