mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Updating formatting.
This commit is contained in:
parent
ccbc6f35f0
commit
7fc14f47b3
1 changed files with 34 additions and 21 deletions
|
@ -145,6 +145,7 @@ class Shell extends Object {
|
|||
*/
|
||||
function __construct(&$dispatch) {
|
||||
$vars = array('params', 'args', 'shell', 'shellCommand' => 'command');
|
||||
|
||||
foreach ($vars as $key => $var) {
|
||||
if (is_string($key)) {
|
||||
$this->{$var} =& $dispatch->{$key};
|
||||
|
@ -205,7 +206,8 @@ class Shell extends Object {
|
|||
*/
|
||||
function _welcome() {
|
||||
$this->Dispatch->clear();
|
||||
$this->out("\nWelcome to CakePHP v" . Configure::version() . " Console");
|
||||
$this->out();
|
||||
$this->out('Welcome to CakePHP v' . Configure::version() . ' Console');
|
||||
$this->hr();
|
||||
$this->out('App : '. $this->params['app']);
|
||||
$this->out('Path: '. $this->params['working']);
|
||||
|
@ -224,8 +226,8 @@ class Shell extends Object {
|
|||
$this->DbConfig =& new DATABASE_CONFIG();
|
||||
return true;
|
||||
}
|
||||
$this->err('Database config could not be loaded');
|
||||
$this->out('Run \'bake\' to create the database configuration');
|
||||
$this->err('Database config could not be loaded.');
|
||||
$this->out('Run `bake` to create the database configuration.');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -320,7 +322,7 @@ class Shell extends Object {
|
|||
}
|
||||
|
||||
if (!isset($this->{$taskName})) {
|
||||
$this->err("Task '" . $taskName . "' could not be loaded");
|
||||
$this->err("Task `{$taskName}` could not be loaded");
|
||||
$this->_stop();
|
||||
}
|
||||
}
|
||||
|
@ -444,7 +446,11 @@ class Shell extends Object {
|
|||
$command = $this->command;
|
||||
}
|
||||
if (count($this->args) < $expectedNum) {
|
||||
$this->error("Wrong number of parameters: ".count($this->args), "Expected: {$expectedNum}\nPlease type 'cake {$this->shell} help' for help on usage of the {$this->name} {$command}");
|
||||
$message[] = "Got: " . count($this->args);
|
||||
$message[] = "Expected: {$expectedNum}";
|
||||
$message[] = "Please type `cake {$this->shell} help` for help";
|
||||
$message[] = "on usage of the {$this->name} {$command}.";
|
||||
$this->error('Wrong number of parameters', $message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -458,14 +464,19 @@ class Shell extends Object {
|
|||
*/
|
||||
function createFile($path, $contents) {
|
||||
$path = str_replace(DS . DS, DS, $path);
|
||||
$this->out($this->nl() . sprintf(__("Creating file %s", true), $path));
|
||||
|
||||
$this->out();
|
||||
$this->out(sprintf(__("Creating file %s", true), $path));
|
||||
|
||||
if (is_file($path) && $this->interactive === true) {
|
||||
$key = $this->in(__("File exists, overwrite?", true). " {$path}", array('y', 'n', 'q'), 'n');
|
||||
$prompt = sprintf(__('File `%s` exists, overwrite?', true), $path);
|
||||
$key = $this->in($prompt, array('y', 'n', 'q'), 'n');
|
||||
|
||||
if (strtolower($key) == 'q') {
|
||||
$this->out(__("Quitting.", true), 2);
|
||||
exit;
|
||||
$this->out(__('Quitting.', true), 2);
|
||||
$this->_stop();
|
||||
} elseif (strtolower($key) != 'y') {
|
||||
$this->out(__("Skip", true) ." {$path}", 2);
|
||||
$this->out(sprintf(__('Skip `%s`', true), $path), 2);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -476,10 +487,10 @@ class Shell extends Object {
|
|||
if ($File = new File($path, true)) {
|
||||
$data = $File->prepare($contents);
|
||||
$File->write($data);
|
||||
$this->out(__("Wrote", true) ." {$path}");
|
||||
$this->out(sprintf(__('Wrote `%s`', true), $path));
|
||||
return true;
|
||||
} else {
|
||||
$this->err(__("Error! Could not write to", true)." {$path}", 2);
|
||||
$this->err(sprintf(__('Could not write to `%s`.', true), $path), 2);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -491,8 +502,8 @@ class Shell extends Object {
|
|||
*/
|
||||
function help() {
|
||||
if ($this->command != null) {
|
||||
$this->err("Unknown {$this->name} command '$this->command'.");
|
||||
$this->err("For usage, try 'cake {$this->shell} help'.", 2);
|
||||
$this->err("Unknown {$this->name} command `{$this->command}`.");
|
||||
$this->err("For usage, try `cake {$this->shell} help`.", 2);
|
||||
} else {
|
||||
$this->Dispatch->help();
|
||||
}
|
||||
|
@ -508,11 +519,13 @@ class Shell extends Object {
|
|||
if (App::import('vendor', 'simpletest' . DS . 'simpletest')) {
|
||||
return true;
|
||||
}
|
||||
$unitTest = $this->in('SimpleTest is not installed. Do you want to bake unit test files anyway?', array('y','n'), 'y');
|
||||
$prompt = 'SimpleTest is not installed. Do you want to bake unit test files anyway?';
|
||||
$unitTest = $this->in($prompt, array('y','n'), 'y');
|
||||
$result = strtolower($unitTest) == 'y' || strtolower($unitTest) == 'yes';
|
||||
|
||||
if ($result) {
|
||||
$this->out("\nYou can download SimpleTest from http://simpletest.org", true);
|
||||
$this->out();
|
||||
$this->out('You can download SimpleTest from http://simpletest.org');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
@ -582,8 +595,7 @@ class Shell extends Object {
|
|||
* @access protected
|
||||
*/
|
||||
function _modelNameFromKey($key) {
|
||||
$name = str_replace('_id', '',$key);
|
||||
return Inflector::camelize($name);
|
||||
return Inflector::camelize(str_replace('_id', '', $key));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -639,6 +651,7 @@ class Shell extends Object {
|
|||
function _pluginPath($pluginName) {
|
||||
$pluginPaths = App::path('plugins');
|
||||
$pluginDirName = Inflector::underscore($pluginName);
|
||||
|
||||
foreach ($pluginPaths as $path) {
|
||||
if (is_dir($path . $pluginDirName)) {
|
||||
return $path . $pluginDirName . DS ;
|
||||
|
|
Loading…
Reference in a new issue