final public static function Database::renameConnection in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Database/Database.php \Drupal\Core\Database\Database::renameConnection()
Rename a connection and its corresponding connection information.
Parameters
string $old_key: The old connection key.
string $new_key: The new connection key.
Return value
bool TRUE in case of success, FALSE otherwise.
6 calls to Database::renameConnection()
- BrowserTestBase::changeDatabasePrefix in core/
modules/ simpletest/ src/ BrowserTestBase.php - Changes the database connection to the prefixed one.
- KernelTestBase::getDatabaseConnectionInfo in core/
tests/ Drupal/ KernelTests/ KernelTestBase.php - Returns the Database connection info to be used for this test.
- MigrateTestBase::cleanupMigrateConnection in core/
modules/ migrate/ src/ Tests/ MigrateTestBase.php - Cleans up the test migrate connection.
- MigrateTestBase::createMigrationConnection in core/
modules/ migrate/ src/ Tests/ MigrateTestBase.php - Changes the database connection to the prefixed one.
- TestBase::changeDatabasePrefix in core/
modules/ simpletest/ src/ TestBase.php - Changes the database connection to the prefixed one.
File
- core/
lib/ Drupal/ Core/ Database/ Database.php, line 311 - Contains \Drupal\Core\Database\Database.
Class
- Database
- Primary front-controller for the database system.
Namespace
Drupal\Core\DatabaseCode
public static final function renameConnection($old_key, $new_key) {
if (!empty(self::$databaseInfo[$old_key]) && empty(self::$databaseInfo[$new_key])) {
// Migrate the database connection information.
self::$databaseInfo[$new_key] = self::$databaseInfo[$old_key];
unset(self::$databaseInfo[$old_key]);
// Migrate over the DatabaseConnection object if it exists.
if (isset(self::$connections[$old_key])) {
self::$connections[$new_key] = self::$connections[$old_key];
unset(self::$connections[$old_key]);
}
return TRUE;
}
else {
return FALSE;
}
}