Skip to content

Commit

Permalink
Adding visibility and static keywords to connection manager.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jul 6, 2010
1 parent 5d8e27d commit cbccd16
Showing 1 changed file with 10 additions and 29 deletions.
39 changes: 10 additions & 29 deletions cake/libs/model/connection_manager.php
Expand Up @@ -28,7 +28,7 @@
* @package cake
* @subpackage cake.cake.libs.model
*/
class ConnectionManager extends Object {
class ConnectionManager {

/**
* Holds a loaded instance of the Connections object
Expand Down Expand Up @@ -69,10 +69,8 @@ function __construct() {
* 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) {
Expand All @@ -87,10 +85,8 @@ function &getInstance() {
*
* @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])) {
Expand Down Expand Up @@ -122,10 +118,8 @@ function &getDataSource($name) {
* 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);
}
Expand All @@ -138,10 +132,8 @@ function sourceList() {
* @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) {
Expand All @@ -158,10 +150,8 @@ function getSourceName(&$source) {
* 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)) {
Expand Down Expand Up @@ -193,12 +183,9 @@ function loadDataSource($connName) {
*
* @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;
}

Expand All @@ -208,10 +195,8 @@ function enumConnectionObjects() {
* @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)) {
Expand All @@ -228,10 +213,8 @@ function &create($name = '', $config = array()) {
* 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) {
Expand All @@ -247,9 +230,8 @@ function _getConnectionObjects() {
* 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';
}
Expand Down Expand Up @@ -285,7 +267,6 @@ function __connectionData($config) {
/**
* Destructor.
*
* @access private
*/
function __destruct() {
if (Configure::read('Session.save') == 'database' && function_exists('session_write_close')) {
Expand Down

0 comments on commit cbccd16

Please sign in to comment.