mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-06 11:32:40 +00:00
Adding a ConenctionManager::drop() method useful for testing and other dynamic tasks
This commit is contained in:
parent
c80a51a163
commit
f14a295a3e
2 changed files with 39 additions and 2 deletions
|
@ -201,8 +201,7 @@ class ConnectionManager {
|
|||
}
|
||||
|
||||
if (empty($name) || empty($config) || array_key_exists($name, self::$_connectionsEnum)) {
|
||||
$null = null;
|
||||
return $null;
|
||||
return null;
|
||||
}
|
||||
self::$config->{$name} = $config;
|
||||
self::$_connectionsEnum[$name] = self::_connectionData($config);
|
||||
|
@ -210,6 +209,24 @@ class ConnectionManager {
|
|||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a connection configuration at runtime given its name
|
||||
*
|
||||
* @param string $name the connection name as it was created
|
||||
* @return boolean success if connection was removed, false if it does not exist
|
||||
*/
|
||||
public static function drop($name) {
|
||||
if (empty(self::$_init)) {
|
||||
self::init();
|
||||
}
|
||||
|
||||
if (!isset(self::$config->{$name})) {
|
||||
return false;
|
||||
}
|
||||
unset(self::$_connectionsEnum[$name], self::$_dataSources[$name], self::$config->{$name});
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of class and file names associated with the user-defined DataSource connections
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue