mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-27 12:12:57 +00:00
updating console_script
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4996 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
0bdb6d7e1d
commit
a335a68aea
1 changed files with 34 additions and 10 deletions
|
@ -66,19 +66,43 @@ class ConsoleScript extends Object {
|
||||||
*/
|
*/
|
||||||
var $args = array();
|
var $args = array();
|
||||||
/**
|
/**
|
||||||
* Initializes this CakeConsoleScript instance.
|
* Initializes this ConsoleScript instance.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function __construct(&$dispatch) {
|
function __construct(&$dispatch) {
|
||||||
$this->dispatch =& $dispatch;
|
$this->dispatch =& $dispatch;
|
||||||
$this->params = $this->dispatch->params;
|
$this->params = $this->dispatch->params;
|
||||||
$this->args = $this->dispatch->args;
|
$this->args = $this->dispatch->args;
|
||||||
if(file_exists(CONFIGS.'database.php')) {
|
if($this->_loadDbConfig()) {
|
||||||
require_once (CONFIGS . 'database.php');
|
$this->_loadModel();
|
||||||
$this->dbConfig = new DATABASE_CONFIG();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _loadDbConfig() {
|
||||||
|
if(config('database')) {
|
||||||
|
if (class_exists('DATABASE_CONFIG')) {
|
||||||
|
$this->dbConfig = new DATABASE_CONFIG();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//$this->err('Database config could not be loaded');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _loadModel() {
|
||||||
|
uses ('model'.DS.'connection_manager',
|
||||||
|
'model'.DS.'datasources'.DS.'dbo_source', 'model'.DS.'model'
|
||||||
|
);
|
||||||
|
|
||||||
|
if(loadModel()) {
|
||||||
|
$this->AppModel = & new AppModel();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//$this->err('AppModel could not be loaded');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main-loop method.
|
* Main-loop method.
|
||||||
*
|
*
|
||||||
|
@ -177,17 +201,17 @@ class ConsoleScript extends Object {
|
||||||
$path = str_replace(DS . DS, DS, $path);
|
$path = str_replace(DS . DS, DS, $path);
|
||||||
echo "\nCreating file $path\n";
|
echo "\nCreating file $path\n";
|
||||||
if (is_file($path) && $this->interactive === true) {
|
if (is_file($path) && $this->interactive === true) {
|
||||||
fwrite($this->stdout, __("File exists, overwrite?", true). " {$path} (y/n/q):");
|
$this->out(__("File exists, overwrite?", true). " {$path} (y/n/q):");
|
||||||
$key = trim(fgets($this->stdin));
|
$key = trim(fgets($this->stdin));
|
||||||
|
|
||||||
if ($key == 'q') {
|
if ($key == 'q') {
|
||||||
fwrite($this->stdout, __("Quitting.", true) ."\n");
|
$this->out(__("Quitting.", true) ."\n");
|
||||||
exit;
|
exit;
|
||||||
} elseif ($key == 'a') {
|
} elseif ($key == 'a') {
|
||||||
$this->dont_ask = true;
|
$this->dont_ask = true;
|
||||||
} elseif ($key == 'y') {
|
} elseif ($key == 'y') {
|
||||||
} else {
|
} else {
|
||||||
fwrite($this->stdout, __("Skip", true) ." {$path}\n");
|
$this->out(__("Skip", true) ." {$path}\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,10 +219,10 @@ class ConsoleScript extends Object {
|
||||||
if ($f = fopen($path, 'w')) {
|
if ($f = fopen($path, 'w')) {
|
||||||
fwrite($f, $contents);
|
fwrite($f, $contents);
|
||||||
fclose($f);
|
fclose($f);
|
||||||
fwrite($this->stdout, __("Wrote", true) ."{$path}\n");
|
$this->out(__("Wrote", true) ."{$path}\n");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
fwrite($this->stderr, __("Error! Could not write to", true)." {$path}.\n");
|
$this->err(__("Error! Could not write to", true)." {$path}.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue