mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +00:00
Adding visibility and static keywords to connection manager.
This commit is contained in:
parent
5d8e27d97b
commit
cbccd16c46
1 changed files with 10 additions and 29 deletions
|
@ -28,7 +28,7 @@ include_once CONFIGS . 'database.php';
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.cake.libs.model
|
* @subpackage cake.cake.libs.model
|
||||||
*/
|
*/
|
||||||
class ConnectionManager extends Object {
|
class ConnectionManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds a loaded instance of the Connections object
|
* Holds a loaded instance of the Connections object
|
||||||
|
@ -69,10 +69,8 @@ class ConnectionManager extends Object {
|
||||||
* Gets a reference to the ConnectionManger object instance
|
* Gets a reference to the ConnectionManger object instance
|
||||||
*
|
*
|
||||||
* @return object Instance
|
* @return object Instance
|
||||||
* @access public
|
|
||||||
* @static
|
|
||||||
*/
|
*/
|
||||||
function &getInstance() {
|
public static function &getInstance() {
|
||||||
static $instance = array();
|
static $instance = array();
|
||||||
|
|
||||||
if (!$instance) {
|
if (!$instance) {
|
||||||
|
@ -87,10 +85,8 @@ class ConnectionManager extends Object {
|
||||||
*
|
*
|
||||||
* @param string $name The name of the DataSource, as defined in app/config/database.php
|
* @param string $name The name of the DataSource, as defined in app/config/database.php
|
||||||
* @return object Instance
|
* @return object Instance
|
||||||
* @access public
|
|
||||||
* @static
|
|
||||||
*/
|
*/
|
||||||
function &getDataSource($name) {
|
public static function &getDataSource($name) {
|
||||||
$_this =& ConnectionManager::getInstance();
|
$_this =& ConnectionManager::getInstance();
|
||||||
|
|
||||||
if (!empty($_this->_dataSources[$name])) {
|
if (!empty($_this->_dataSources[$name])) {
|
||||||
|
@ -122,10 +118,8 @@ class ConnectionManager extends Object {
|
||||||
* Gets the list of available DataSource connections
|
* Gets the list of available DataSource connections
|
||||||
*
|
*
|
||||||
* @return array List of available connections
|
* @return array List of available connections
|
||||||
* @access public
|
|
||||||
* @static
|
|
||||||
*/
|
*/
|
||||||
function sourceList() {
|
public static function sourceList() {
|
||||||
$_this =& ConnectionManager::getInstance();
|
$_this =& ConnectionManager::getInstance();
|
||||||
return array_keys($_this->_dataSources);
|
return array_keys($_this->_dataSources);
|
||||||
}
|
}
|
||||||
|
@ -138,10 +132,8 @@ class ConnectionManager extends Object {
|
||||||
* @param object $source DataSource object
|
* @param object $source DataSource object
|
||||||
* @return string Datasource name, or null if source is not present
|
* @return string Datasource name, or null if source is not present
|
||||||
* in the ConnectionManager.
|
* in the ConnectionManager.
|
||||||
* @access public
|
|
||||||
* @static
|
|
||||||
*/
|
*/
|
||||||
function getSourceName(&$source) {
|
public static function getSourceName(&$source) {
|
||||||
$_this =& ConnectionManager::getInstance();
|
$_this =& ConnectionManager::getInstance();
|
||||||
foreach ($_this->_dataSources as $name => $ds) {
|
foreach ($_this->_dataSources as $name => $ds) {
|
||||||
if ($ds == $source) {
|
if ($ds == $source) {
|
||||||
|
@ -158,10 +150,8 @@ class ConnectionManager extends Object {
|
||||||
* or an array containing the filename (without extension) and class name of the object,
|
* or an array containing the filename (without extension) and class name of the object,
|
||||||
* to be found in app/models/datasources/ or cake/libs/model/datasources/.
|
* to be found in app/models/datasources/ or cake/libs/model/datasources/.
|
||||||
* @return boolean True on success, null on failure or false if the class is already loaded
|
* @return boolean True on success, null on failure or false if the class is already loaded
|
||||||
* @access public
|
|
||||||
* @static
|
|
||||||
*/
|
*/
|
||||||
function loadDataSource($connName) {
|
public static function loadDataSource($connName) {
|
||||||
$_this =& ConnectionManager::getInstance();
|
$_this =& ConnectionManager::getInstance();
|
||||||
|
|
||||||
if (is_array($connName)) {
|
if (is_array($connName)) {
|
||||||
|
@ -193,12 +183,9 @@ class ConnectionManager extends Object {
|
||||||
*
|
*
|
||||||
* @return array An associative array of elements where the key is the connection name
|
* @return array An associative array of elements where the key is the connection name
|
||||||
* (as defined in Connections), and the value is an array with keys 'filename' and 'classname'.
|
* (as defined in Connections), and the value is an array with keys 'filename' and 'classname'.
|
||||||
* @access public
|
|
||||||
* @static
|
|
||||||
*/
|
*/
|
||||||
function enumConnectionObjects() {
|
public static function enumConnectionObjects() {
|
||||||
$_this =& ConnectionManager::getInstance();
|
$_this =& ConnectionManager::getInstance();
|
||||||
|
|
||||||
return $_this->_connectionsEnum;
|
return $_this->_connectionsEnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,10 +195,8 @@ class ConnectionManager extends Object {
|
||||||
* @param string $name The DataSource name
|
* @param string $name The DataSource name
|
||||||
* @param array $config The DataSource configuration settings
|
* @param array $config The DataSource configuration settings
|
||||||
* @return object A reference to the DataSource object, or null if creation failed
|
* @return object A reference to the DataSource object, or null if creation failed
|
||||||
* @access public
|
|
||||||
* @static
|
|
||||||
*/
|
*/
|
||||||
function &create($name = '', $config = array()) {
|
public static function &create($name = '', $config = array()) {
|
||||||
$_this =& ConnectionManager::getInstance();
|
$_this =& ConnectionManager::getInstance();
|
||||||
|
|
||||||
if (empty($name) || empty($config) || array_key_exists($name, $_this->_connectionsEnum)) {
|
if (empty($name) || empty($config) || array_key_exists($name, $_this->_connectionsEnum)) {
|
||||||
|
@ -228,10 +213,8 @@ class ConnectionManager extends Object {
|
||||||
* Gets a list of class and file names associated with the user-defined DataSource connections
|
* Gets a list of class and file names associated with the user-defined DataSource connections
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @access protected
|
|
||||||
* @static
|
|
||||||
*/
|
*/
|
||||||
function _getConnectionObjects() {
|
protected function _getConnectionObjects() {
|
||||||
$connections = get_object_vars($this->config);
|
$connections = get_object_vars($this->config);
|
||||||
|
|
||||||
if ($connections != null) {
|
if ($connections != null) {
|
||||||
|
@ -247,9 +230,8 @@ class ConnectionManager extends Object {
|
||||||
* Returns the file, class name, and parent for the given driver.
|
* Returns the file, class name, and parent for the given driver.
|
||||||
*
|
*
|
||||||
* @return array An indexed array with: filename, classname, plugin and parent
|
* @return array An indexed array with: filename, classname, plugin and parent
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
function __connectionData($config) {
|
private function __connectionData($config) {
|
||||||
if (!isset($config['datasource'])) {
|
if (!isset($config['datasource'])) {
|
||||||
$config['datasource'] = 'dbo';
|
$config['datasource'] = 'dbo';
|
||||||
}
|
}
|
||||||
|
@ -285,7 +267,6 @@ class ConnectionManager extends Object {
|
||||||
/**
|
/**
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*
|
*
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
function __destruct() {
|
function __destruct() {
|
||||||
if (Configure::read('Session.save') == 'database' && function_exists('session_write_close')) {
|
if (Configure::read('Session.save') == 'database' && function_exists('session_write_close')) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue