mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +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();
|
||||
/**
|
||||
* Initializes this CakeConsoleScript instance.
|
||||
* Initializes this ConsoleScript instance.
|
||||
*
|
||||
*/
|
||||
function __construct(&$dispatch) {
|
||||
$this->dispatch =& $dispatch;
|
||||
$this->params = $this->dispatch->params;
|
||||
$this->args = $this->dispatch->args;
|
||||
if(file_exists(CONFIGS.'database.php')) {
|
||||
require_once (CONFIGS . 'database.php');
|
||||
$this->dbConfig = new DATABASE_CONFIG();
|
||||
if($this->_loadDbConfig()) {
|
||||
$this->_loadModel();
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
|
@ -177,17 +201,17 @@ class ConsoleScript extends Object {
|
|||
$path = str_replace(DS . DS, DS, $path);
|
||||
echo "\nCreating file $path\n";
|
||||
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));
|
||||
|
||||
if ($key == 'q') {
|
||||
fwrite($this->stdout, __("Quitting.", true) ."\n");
|
||||
$this->out(__("Quitting.", true) ."\n");
|
||||
exit;
|
||||
} elseif ($key == 'a') {
|
||||
$this->dont_ask = true;
|
||||
} elseif ($key == 'y') {
|
||||
} else {
|
||||
fwrite($this->stdout, __("Skip", true) ." {$path}\n");
|
||||
$this->out(__("Skip", true) ." {$path}\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -195,10 +219,10 @@ class ConsoleScript extends Object {
|
|||
if ($f = fopen($path, 'w')) {
|
||||
fwrite($f, $contents);
|
||||
fclose($f);
|
||||
fwrite($this->stdout, __("Wrote", true) ."{$path}\n");
|
||||
$this->out(__("Wrote", true) ."{$path}\n");
|
||||
return true;
|
||||
} else {
|
||||
fwrite($this->stderr, __("Error! Could not write to", true)." {$path}.\n");
|
||||
$this->err(__("Error! Could not write to", true)." {$path}.\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue