1 config.inc | public ConfigDatabaseStorage::write($name, array $data) |
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.
Overrides ConfigStorageInterface::write
File
- core/
includes/ config.inc, line 1436 - This is the API for configuration storage.
Class
- ConfigDatabaseStorage
- Defines the database storage controller.
Code
public function write($name, array $data) {
// Ensure that the config name is included in the written file.
$data = array_merge(array('_config_name' => $name), $data);
$data = $this->encode($data) . "\n";
try {
db_merge($this->table, array('target' => $this->database))
->key(array('name' => $name))
->fields(array(
'name' => $name,
'data' => $data,
'changed' => REQUEST_TIME,
))
->execute();
}
catch (\Exception $e) {
throw new ConfigStorageException('Failed to write configuration to the database: ' . $this->$name, 0, $e);
}
return TRUE;
}