mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-04 10:32:40 +00:00
Replacing self with static due to PHP5.3+. Following #7040.
This commit is contained in:
parent
27e40f084d
commit
52e79987a2
53 changed files with 998 additions and 998 deletions
|
@ -66,9 +66,9 @@ class ConnectionManager {
|
|||
protected static function _init() {
|
||||
include_once APP . 'Config' . DS . 'database.php';
|
||||
if (class_exists('DATABASE_CONFIG')) {
|
||||
self::$config = new DATABASE_CONFIG();
|
||||
static::$config = new DATABASE_CONFIG();
|
||||
}
|
||||
self::$_init = true;
|
||||
static::$_init = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,20 +79,20 @@ class ConnectionManager {
|
|||
* @throws MissingDatasourceException
|
||||
*/
|
||||
public static function getDataSource($name) {
|
||||
if (empty(self::$_init)) {
|
||||
self::_init();
|
||||
if (empty(static::$_init)) {
|
||||
static::_init();
|
||||
}
|
||||
|
||||
if (!empty(self::$_dataSources[$name])) {
|
||||
return self::$_dataSources[$name];
|
||||
if (!empty(static::$_dataSources[$name])) {
|
||||
return static::$_dataSources[$name];
|
||||
}
|
||||
|
||||
if (empty(self::$_connectionsEnum[$name])) {
|
||||
self::_getConnectionObject($name);
|
||||
if (empty(static::$_connectionsEnum[$name])) {
|
||||
static::_getConnectionObject($name);
|
||||
}
|
||||
|
||||
self::loadDataSource($name);
|
||||
$conn = self::$_connectionsEnum[$name];
|
||||
static::loadDataSource($name);
|
||||
$conn = static::$_connectionsEnum[$name];
|
||||
$class = $conn['classname'];
|
||||
|
||||
if (strpos(App::location($class), 'Datasource') === false) {
|
||||
|
@ -102,10 +102,10 @@ class ConnectionManager {
|
|||
'message' => 'Datasource is not found in Model/Datasource package.'
|
||||
));
|
||||
}
|
||||
self::$_dataSources[$name] = new $class(self::$config->{$name});
|
||||
self::$_dataSources[$name]->configKeyName = $name;
|
||||
static::$_dataSources[$name] = new $class(static::$config->{$name});
|
||||
static::$_dataSources[$name]->configKeyName = $name;
|
||||
|
||||
return self::$_dataSources[$name];
|
||||
return static::$_dataSources[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,10 +116,10 @@ class ConnectionManager {
|
|||
* @return array List of available connections
|
||||
*/
|
||||
public static function sourceList() {
|
||||
if (empty(self::$_init)) {
|
||||
self::_init();
|
||||
if (empty(static::$_init)) {
|
||||
static::_init();
|
||||
}
|
||||
return array_keys(self::$_dataSources);
|
||||
return array_keys(static::$_dataSources);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -130,10 +130,10 @@ class ConnectionManager {
|
|||
* in the ConnectionManager.
|
||||
*/
|
||||
public static function getSourceName($source) {
|
||||
if (empty(self::$_init)) {
|
||||
self::_init();
|
||||
if (empty(static::$_init)) {
|
||||
static::_init();
|
||||
}
|
||||
foreach (self::$_dataSources as $name => $ds) {
|
||||
foreach (static::$_dataSources as $name => $ds) {
|
||||
if ($ds === $source) {
|
||||
return $name;
|
||||
}
|
||||
|
@ -151,14 +151,14 @@ class ConnectionManager {
|
|||
* @throws MissingDatasourceException
|
||||
*/
|
||||
public static function loadDataSource($connName) {
|
||||
if (empty(self::$_init)) {
|
||||
self::_init();
|
||||
if (empty(static::$_init)) {
|
||||
static::_init();
|
||||
}
|
||||
|
||||
if (is_array($connName)) {
|
||||
$conn = $connName;
|
||||
} else {
|
||||
$conn = self::$_connectionsEnum[$connName];
|
||||
$conn = static::$_connectionsEnum[$connName];
|
||||
}
|
||||
|
||||
if (class_exists($conn['classname'], false)) {
|
||||
|
@ -190,10 +190,10 @@ class ConnectionManager {
|
|||
* (as defined in Connections), and the value is an array with keys 'filename' and 'classname'.
|
||||
*/
|
||||
public static function enumConnectionObjects() {
|
||||
if (empty(self::$_init)) {
|
||||
self::_init();
|
||||
if (empty(static::$_init)) {
|
||||
static::_init();
|
||||
}
|
||||
return (array)self::$config;
|
||||
return (array)static::$config;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -204,16 +204,16 @@ class ConnectionManager {
|
|||
* @return DataSource|null A reference to the DataSource object, or null if creation failed
|
||||
*/
|
||||
public static function create($name = '', $config = array()) {
|
||||
if (empty(self::$_init)) {
|
||||
self::_init();
|
||||
if (empty(static::$_init)) {
|
||||
static::_init();
|
||||
}
|
||||
|
||||
if (empty($name) || empty($config) || array_key_exists($name, self::$_connectionsEnum)) {
|
||||
if (empty($name) || empty($config) || array_key_exists($name, static::$_connectionsEnum)) {
|
||||
return null;
|
||||
}
|
||||
self::$config->{$name} = $config;
|
||||
self::$_connectionsEnum[$name] = self::_connectionData($config);
|
||||
$return = self::getDataSource($name);
|
||||
static::$config->{$name} = $config;
|
||||
static::$_connectionsEnum[$name] = static::_connectionData($config);
|
||||
$return = static::getDataSource($name);
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
@ -224,14 +224,14 @@ class ConnectionManager {
|
|||
* @return bool success if connection was removed, false if it does not exist
|
||||
*/
|
||||
public static function drop($name) {
|
||||
if (empty(self::$_init)) {
|
||||
self::_init();
|
||||
if (empty(static::$_init)) {
|
||||
static::_init();
|
||||
}
|
||||
|
||||
if (!isset(self::$config->{$name})) {
|
||||
if (!isset(static::$config->{$name})) {
|
||||
return false;
|
||||
}
|
||||
unset(self::$_connectionsEnum[$name], self::$_dataSources[$name], self::$config->{$name});
|
||||
unset(static::$_connectionsEnum[$name], static::$_dataSources[$name], static::$config->{$name});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -243,8 +243,8 @@ class ConnectionManager {
|
|||
* @throws MissingDatasourceConfigException
|
||||
*/
|
||||
protected static function _getConnectionObject($name) {
|
||||
if (!empty(self::$config->{$name})) {
|
||||
self::$_connectionsEnum[$name] = self::_connectionData(self::$config->{$name});
|
||||
if (!empty(static::$config->{$name})) {
|
||||
static::$_connectionsEnum[$name] = static::_connectionData(static::$config->{$name});
|
||||
} else {
|
||||
throw new MissingDatasourceConfigException(array('config' => $name));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue