updating bake project, dbconfig, fixes #4563 now using int for port

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6763 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2008-05-05 15:42:02 +00:00
parent 5cb193db6e
commit 2e1f8c6303
3 changed files with 31 additions and 8 deletions

View file

@ -65,9 +65,10 @@ class BakeShell extends Shell {
* @access public
*/
function main() {
if (!is_dir(CONFIGS)) {
$this->Project->execute();
if (!is_dir($this->DbConfig->path)) {
if ($this->Project->execute()) {
$this->DbConfig->path = $this->params['working'] . DS . 'config' . DS;
}
}
if (!config('database')) {

View file

@ -36,6 +36,13 @@ if (!class_exists('File')) {
* @subpackage cake.cake.console.libs.tasks
*/
class DbConfigTask extends Shell {
/**
* path to CONFIG directory
*
* @var string
* @access public
*/
var $path = null;
/**
* Default configuration settings to use
*
@ -45,6 +52,15 @@ class DbConfigTask extends Shell {
var $__defaultConfig = array('name' => 'default', 'driver'=> 'mysql', 'persistent'=> 'false', 'host'=> 'localhost',
'login'=> 'root', 'password'=> 'password', 'database'=> 'project_name',
'schema'=> null, 'prefix'=> null, 'encoding' => null, 'port' => null);
/**
* initialization callback
*
* @var string
* @access public
*/
function initialize() {
$this->path = $this->params['working'] . DS . 'config' . DS;
}
/**
* Execution method always used for tasks
*
@ -62,7 +78,9 @@ class DbConfigTask extends Shell {
* @access private
*/
function __interactive() {
$this->hr();
$this->out('Database Configuration:');
$this->hr();
$done = false;
$dbConfigs = array();
@ -219,12 +237,12 @@ class DbConfigTask extends Shell {
* @access public
*/
function bake($configs) {
if (!is_dir(CONFIGS)) {
$this->err(CONFIGS .' not found');
if (!is_dir($this->path)) {
$this->err($this->path . ' not found');
return false;
}
$filename = CONFIGS.'database.php';
$filename = $this->path . 'database.php';
$oldConfigs = array();
if (file_exists($filename)) {
@ -281,7 +299,7 @@ class DbConfigTask extends Shell {
$out .= "\t\t'driver' => '{$driver}',\n";
$out .= "\t\t'persistent' => {$persistent},\n";
$out .= "\t\t'host' => '{$host}',\n";
$out .= "\t\t'port' => '{$port}',\n";
$out .= "\t\t'port' => {$port},\n";
$out .= "\t\t'login' => '{$login}',\n";
$out .= "\t\t'password' => '{$password}',\n";
$out .= "\t\t'database' => '{$database}',\n";
@ -293,7 +311,7 @@ class DbConfigTask extends Shell {
$out .= "}\n";
$out .= "?>";
$filename = CONFIGS.'database.php';
$filename = $this->path.'database.php';
return $this->createFile($filename, $out);
}
}

View file

@ -111,6 +111,9 @@ class ProjectTask extends Shell {
}
if($this->bake($project)) {
$this->params['app'] = basename($project);
$this->params['working'] = $project;
$path = Folder::slashTerm($project);
if ($this->createHome($path)) {
$this->out(__('Welcome page created', true));
@ -137,6 +140,7 @@ class ProjectTask extends Shell {
$this->err(sprintf(__('Could not set permissions on %s', true), $path . DS .'tmp'));
$this->out(sprintf(__('chmod -R 0777 %s', true), $path . DS .'tmp'));
}
return true;
}
}
/**