mirror of
https://github.com/brmlab/brmsklad.git
synced 2025-08-03 06:33:38 +02:00
Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
parent
5a580df460
commit
235a541597
793 changed files with 60746 additions and 23753 deletions
|
@ -4,19 +4,18 @@
|
|||
*
|
||||
* Provides an interface for loading and enumerating connections defined in app/Config/database.php
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.Model
|
||||
* @since CakePHP(tm) v 0.10.x.1402
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('DataSource', 'Model/Datasource');
|
||||
|
@ -55,7 +54,7 @@ class ConnectionManager {
|
|||
/**
|
||||
* Indicates if the init code for this class has already been executed
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
protected static $_init = false;
|
||||
|
||||
|
@ -67,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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,31 +76,36 @@ class ConnectionManager {
|
|||
*
|
||||
* @param string $name The name of the DataSource, as defined in app/Config/database.php
|
||||
* @return DataSource Instance
|
||||
* @throws MissingDatasourceConfigException
|
||||
* @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];
|
||||
return $return;
|
||||
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'];
|
||||
|
||||
self::$_dataSources[$name] = new $class(self::$config->{$name});
|
||||
self::$_dataSources[$name]->configKeyName = $name;
|
||||
if (strpos(App::location($class), 'Datasource') === false) {
|
||||
throw new MissingDatasourceException(array(
|
||||
'class' => $class,
|
||||
'plugin' => null,
|
||||
'message' => 'Datasource is not found in Model/Datasource package.'
|
||||
));
|
||||
}
|
||||
static::$_dataSources[$name] = new $class(static::$config->{$name});
|
||||
static::$_dataSources[$name]->configKeyName = $name;
|
||||
|
||||
return self::$_dataSources[$name];
|
||||
return static::$_dataSources[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,24 +116,24 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a DataSource name from an object reference.
|
||||
*
|
||||
* @param DataSource $source DataSource object
|
||||
* @return string Datasource name, or null if source is not present
|
||||
* @return string|null Datasource name, or null if source is not present
|
||||
* 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;
|
||||
}
|
||||
|
@ -141,20 +145,20 @@ class ConnectionManager {
|
|||
* Loads the DataSource class for the given connection name
|
||||
*
|
||||
* @param string|array $connName A string name of the connection, as defined in app/Config/database.php,
|
||||
* or an array containing the filename (without extension) and class name of the object,
|
||||
* to be found in app/Model/Datasource/ or lib/Cake/Model/Datasource/.
|
||||
* @return boolean True on success, null on failure or false if the class is already loaded
|
||||
* or an array containing the filename (without extension) and class name of the object,
|
||||
* to be found in app/Model/Datasource/ or lib/Cake/Model/Datasource/.
|
||||
* @return bool True on success, null on failure or false if the class is already loaded
|
||||
* @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)) {
|
||||
|
@ -180,16 +184,16 @@ class ConnectionManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return a list of connections
|
||||
* Returns a list of connections
|
||||
*
|
||||
* @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'.
|
||||
*/
|
||||
public static function enumConnectionObjects() {
|
||||
if (empty(self::$_init)) {
|
||||
self::_init();
|
||||
if (empty(static::$_init)) {
|
||||
static::_init();
|
||||
}
|
||||
return (array)self::$config;
|
||||
return (array)static::$config;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -197,19 +201,19 @@ class ConnectionManager {
|
|||
*
|
||||
* @param string $name The DataSource name
|
||||
* @param array $config The DataSource configuration settings
|
||||
* @return DataSource A reference to the DataSource object, or null if creation failed
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
@ -217,17 +221,17 @@ class ConnectionManager {
|
|||
* 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
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
@ -239,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