From cbccd16c462ed9d00527e8e78b64678219f5de27 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 5 Jul 2010 23:08:25 -0400 Subject: [PATCH] Adding visibility and static keywords to connection manager. --- cake/libs/model/connection_manager.php | 39 +++++++------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/cake/libs/model/connection_manager.php b/cake/libs/model/connection_manager.php index 3247742c4..34a355108 100644 --- a/cake/libs/model/connection_manager.php +++ b/cake/libs/model/connection_manager.php @@ -28,7 +28,7 @@ include_once CONFIGS . 'database.php'; * @package cake * @subpackage cake.cake.libs.model */ -class ConnectionManager extends Object { +class ConnectionManager { /** * Holds a loaded instance of the Connections object @@ -69,10 +69,8 @@ class ConnectionManager extends Object { * Gets a reference to the ConnectionManger object instance * * @return object Instance - * @access public - * @static */ - function &getInstance() { + public static function &getInstance() { static $instance = array(); 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 * @return object Instance - * @access public - * @static */ - function &getDataSource($name) { + public static function &getDataSource($name) { $_this =& ConnectionManager::getInstance(); if (!empty($_this->_dataSources[$name])) { @@ -122,10 +118,8 @@ class ConnectionManager extends Object { * Gets the list of available DataSource connections * * @return array List of available connections - * @access public - * @static */ - function sourceList() { + public static function sourceList() { $_this =& ConnectionManager::getInstance(); return array_keys($_this->_dataSources); } @@ -138,10 +132,8 @@ class ConnectionManager extends Object { * @param object $source DataSource object * @return string Datasource name, or null if source is not present * in the ConnectionManager. - * @access public - * @static */ - function getSourceName(&$source) { + public static function getSourceName(&$source) { $_this =& ConnectionManager::getInstance(); foreach ($_this->_dataSources as $name => $ds) { 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, * 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 - * @access public - * @static */ - function loadDataSource($connName) { + public static function loadDataSource($connName) { $_this =& ConnectionManager::getInstance(); 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 * (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(); - return $_this->_connectionsEnum; } @@ -208,10 +195,8 @@ class ConnectionManager extends Object { * @param string $name The DataSource name * @param array $config The DataSource configuration settings * @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(); 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 * * @return void - * @access protected - * @static */ - function _getConnectionObjects() { + protected function _getConnectionObjects() { $connections = get_object_vars($this->config); if ($connections != null) { @@ -247,9 +230,8 @@ class ConnectionManager extends Object { * Returns the file, class name, and parent for the given driver. * * @return array An indexed array with: filename, classname, plugin and parent - * @access private */ - function __connectionData($config) { + private function __connectionData($config) { if (!isset($config['datasource'])) { $config['datasource'] = 'dbo'; } @@ -285,7 +267,6 @@ class ConnectionManager extends Object { /** * Destructor. * - * @access private */ function __destruct() { if (Configure::read('Session.save') == 'database' && function_exists('session_write_close')) {