1.20.x config_database_storage.inc | public ConfigDatabaseStorage::rename($name, $new_name) |
Renames a configuration object in the storage.
Parameters
string $name: The name of a configuration object to rename.
string $new_name: The new name of a configuration object.
Return value
bool: TRUE on success, FALSE otherwise.
Overrides ConfigStorageInterface::rename
File
- drivers/
config_database/ config_database_storage.inc, line 246
Class
- ConfigDatabaseStorage
- Defines the database storage controller.
Code
public function rename($name, $new_name) {
try {
db_delete($this->table, array('target' => $this->database))
->condition('name', $new_name)
->execute();
db_update($this->table, array('target' => $this->database))
->fields(array('name' => $new_name))
->condition('name', $name)
->execute();
}
catch (\Exception $e) {
throw new ConfigStorageException('Failed to rename configuration file from: ' . $this->getFilePath($name) . ' to: ' . $this->getFilePath($new_name), 0, $e);
}
return TRUE;
}