public function MongodbConfigStorage::rename in MongoDB 8
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 StorageInterface::rename
File
- src/
MongodbConfigStorage.php, line 113 - Definition of Drupal\mongodb\Config\MongoStorage.
Class
Namespace
Drupal\mongodbCode
public function rename($name, $new_name) {
try {
$collection = $this
->mongoCollection();
$item = $collection
->findOne(array(
'_id' => $name,
));
if (empty($item)) {
return FALSE;
}
$item['_id'] = $new_name;
$result = $collection
->insert($item);
if (!empty($result['err'])) {
return FALSE;
}
$collection
->remove(array(
'_id' => $name,
));
} catch (\Exception $e) {
return FALSE;
}
return TRUE;
}