You are here

public function MongodbConfigStorage::write in MongoDB 8

Writes configuration data to the storage.

Parameters

string $name: The name of a configuration object to save.

array $data: The configuration data to write.

Return value

bool TRUE on success, FALSE in case of an error.

Throws

\Drupal\Core\Config\StorageException If the back-end storage does not exist and cannot be created.

Overrides StorageInterface::write

1 call to MongodbConfigStorage::write()
MongodbConfigStorageBootstrap::read in src/MongodbConfigStorageBootstrap.php
Reads configuration data from the storage.

File

src/MongodbConfigStorage.php, line 86
Definition of Drupal\mongodb\Config\MongoStorage.

Class

MongodbConfigStorage

Namespace

Drupal\mongodb

Code

public function write($name, array $data) {
  try {
    $this
      ->mongoCollection()
      ->update(array(
      '_id' => $name,
    ), array(
      '$set' => $data,
    ), array(
      'upsert' => TRUE,
    ));
  } catch (\Exception $e) {
    return FALSE;
  }
  return TRUE;
}