Refactoring out to use DbConfig::getConfig

Continuing fixture bake
This commit is contained in:
mark_story 2009-04-28 20:45:07 -04:00
parent 802ed73c0a
commit 0b40e5c709
2 changed files with 9 additions and 14 deletions

View file

@ -42,7 +42,7 @@ class FixtureTask extends Shell {
* @var array
* @access public
*/
var $tasks = array('Model');
var $tasks = array('DbConfig', 'Model');
/**
* path to fixtures directory
*
@ -107,7 +107,12 @@ class FixtureTask extends Shell {
* @access private
*/
function __interactive($modelName = false) {
$this->interactive = true;
$this->hr();
$this->out(sprintf("Bake Fixture\nPath: %s", $this->path));
$this->hr();
$useDbConfig = $this->DbConfig->getConfig();
}
/**

View file

@ -117,18 +117,8 @@ class ModelTask extends Shell {
$primaryKey = 'id';
$validate = array();
$associations = array('belongsTo'=> array(), 'hasOne'=> array(), 'hasMany' => array(), 'hasAndBelongsToMany'=> array());
$useDbConfig = 'default';
$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');
}
$useDbConfig = $this->DbConfig->getConfig();
$currentModelName = $this->getName($useDbConfig);
$db =& ConnectionManager::getDataSource($useDbConfig);