mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +00:00
Refactoring out to use DbConfig::getConfig
Continuing fixture bake
This commit is contained in:
parent
802ed73c0a
commit
0b40e5c709
2 changed files with 9 additions and 14 deletions
|
@ -42,7 +42,7 @@ class FixtureTask extends Shell {
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $tasks = array('Model');
|
var $tasks = array('DbConfig', 'Model');
|
||||||
/**
|
/**
|
||||||
* path to fixtures directory
|
* path to fixtures directory
|
||||||
*
|
*
|
||||||
|
@ -107,7 +107,12 @@ class FixtureTask extends Shell {
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __interactive($modelName = false) {
|
function __interactive($modelName = false) {
|
||||||
|
$this->interactive = true;
|
||||||
|
$this->hr();
|
||||||
|
$this->out(sprintf("Bake Fixture\nPath: %s", $this->path));
|
||||||
|
$this->hr();
|
||||||
|
|
||||||
|
$useDbConfig = $this->DbConfig->getConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -117,18 +117,8 @@ class ModelTask extends Shell {
|
||||||
$primaryKey = 'id';
|
$primaryKey = 'id';
|
||||||
$validate = array();
|
$validate = array();
|
||||||
$associations = array('belongsTo'=> array(), 'hasOne'=> array(), 'hasMany' => array(), 'hasAndBelongsToMany'=> array());
|
$associations = array('belongsTo'=> array(), 'hasOne'=> array(), 'hasMany' => array(), 'hasAndBelongsToMany'=> array());
|
||||||
|
|
||||||
$useDbConfig = 'default';
|
$useDbConfig = $this->DbConfig->getConfig();
|
||||||
$configs = get_class_vars('DATABASE_CONFIG');
|
|
||||||
|
|
||||||
if (!is_array($configs)) {
|
|
||||||
return $this->DbConfig->execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
$connections = array_keys($configs);
|
|
||||||
if (count($connections) > 1) {
|
|
||||||
$useDbConfig = $this->in(__('Use Database Config', true) .':', $connections, 'default');
|
|
||||||
}
|
|
||||||
|
|
||||||
$currentModelName = $this->getName($useDbConfig);
|
$currentModelName = $this->getName($useDbConfig);
|
||||||
$db =& ConnectionManager::getDataSource($useDbConfig);
|
$db =& ConnectionManager::getDataSource($useDbConfig);
|
||||||
|
|
Loading…
Add table
Reference in a new issue