class Connection in MongoDB 8
Hierarchy
- class \Drupal\Driver\Database\mongodb\Connection extends \Drupal\Core\Database\Driver\fake\FakeConnection
Expanded class hierarchy of Connection
1 file declares its use of Connection
- BatchQueueMongodb.php in src/
BatchQueueMongodb.php - QueueMongodb functionality.
File
- drivers/
lib/ Drupal/ Driver/ Database/ mongodb/ Connection.php, line 10
Namespace
Drupal\Driver\Database\mongodbView source
class Connection extends FakeConnection {
protected $transactionSupport = FALSE;
protected $testHelper;
public function __construct(MongoCollectionFactory $mongo) {
$this->mongo = $mongo;
// Connection::destroy needs a connection object.
$this->connection = new DoNothing();
return parent::__construct([], [
'namespace' => __NAMESPACE__,
]);
}
public function version() {
return phpversion('mongo');
}
public static function open(array &$connection_options = array()) {
$mongo_info['servers']['default']['server'] = $connection_options['database'];
return new MongoCollectionFactory($mongo_info);
}
public function schema() {
return new Schema();
}
public function startTransaction($name = '') {
return new DoNothing();
}
public function nextId($existing_id = 0) {
return \Drupal::service('mongo')
->nextId('generic', $existing_id);
}
public function driver() {
return 'mongodb';
}
public function insert($table, array $options = array()) {
$return = FALSE;
if (drupal_valid_test_ua() || $table == 'node_access') {
$return = $this
->getTestHelper()
->insert($table, $options);
}
return $return ?: new FakeInsert($table, $options);
}
public function query($query, array $args = array(), $options = array()) {
if (drupal_valid_test_ua()) {
return $this
->getTestHelper()
->query($query, $args, $options);
}
return parent::query($query, $args, $options);
// TODO: Change the autogenerated stub
}
/**
* {@inheritdoc}
*/
public function update($table, array $options = array()) {
$return = FALSE;
if (drupal_valid_test_ua()) {
$return = $this
->getTestHelper()
->update($table, $options);
}
return $return ?: new FakeUpdate($this->databaseContents, $table);
}
/**
* {@inheritdoc}
*/
public function select($table, $alias = NULL, array $options = array()) {
$return = FALSE;
if (drupal_valid_test_ua()) {
$return = $this
->getTestHelper()
->select($table, $alias, $options);
}
return $return ?: new FakeUpdate($this->databaseContents, $table);
}
/**
* @return TestHelper
*/
public function getTestHelper() {
if (!isset($this->testHelper)) {
$this->testHelper = new DbHelper($this->mongo);
}
return $this->testHelper;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Connection:: |
protected | property | ||
Connection:: |
protected | property | ||
Connection:: |
public | function | ||
Connection:: |
public | function | ||
Connection:: |
public | function | ||
Connection:: |
public | function | ||
Connection:: |
public static | function | ||
Connection:: |
public | function | ||
Connection:: |
public | function | ||
Connection:: |
public | function | ||
Connection:: |
public | function | ||
Connection:: |
public | function | ||
Connection:: |
public | function | ||
Connection:: |
public | function |