mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
adding shell loading from plugins, updating exit from lists controller and model in tasks
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6437 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
1db0c07852
commit
f5de1ac9a2
4 changed files with 41 additions and 18 deletions
|
@ -246,7 +246,13 @@ class ShellDispatcher {
|
|||
$this->stdout("\nWelcome to CakePHP v" . Configure::version() . " Console");
|
||||
$this->stdout("---------------------------------------------------------------");
|
||||
if (isset($this->args[0])) {
|
||||
$this->shell = $this->args[0];
|
||||
$plugin = null;
|
||||
$shell = $this->args[0];
|
||||
if (strpos($shell, '.') !== false) {
|
||||
list($plugin, $shell) = explode('.', $this->args[0]);
|
||||
}
|
||||
|
||||
$this->shell = $shell;
|
||||
$this->shiftArgs();
|
||||
$this->shellName = Inflector::camelize($this->shell);
|
||||
$this->shellClass = $this->shellName . 'Shell';
|
||||
|
@ -255,6 +261,21 @@ class ShellDispatcher {
|
|||
$this->help();
|
||||
} else {
|
||||
$loaded = false;
|
||||
if ($plugin !== null) {
|
||||
$pluginPaths = Configure::read('pluginPaths');
|
||||
$count = count($pluginPaths);
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$paths[] = $pluginPaths[$i] . $plugin . DS . 'vendors' . DS . 'shells' . DS;
|
||||
}
|
||||
}
|
||||
|
||||
$vendorPaths = Configure::read('vendorPaths');
|
||||
$count = count($vendorPaths);
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$paths[] = $vendorPaths[$i] . DS . 'shells' . DS;
|
||||
}
|
||||
|
||||
$this->shellPaths = array_merge($paths, array(CONSOLE_LIBS));
|
||||
foreach ($this->shellPaths as $path) {
|
||||
$this->shellPath = $path . $this->shell . ".php";
|
||||
if (file_exists($this->shellPath)) {
|
||||
|
@ -262,7 +283,7 @@ class ShellDispatcher {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($loaded) {
|
||||
require CONSOLE_LIBS . 'shell.php';
|
||||
require $this->shellPath;
|
||||
|
|
|
@ -209,7 +209,7 @@ class Shell extends Object {
|
|||
);
|
||||
|
||||
if ($this->uses === true && App::import('Model', 'AppModel')) {
|
||||
$this->AppModel = & new AppModel(false, false, false);
|
||||
$this->AppModel =& new AppModel(false, false, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -218,18 +218,10 @@ class Shell extends Object {
|
|||
$this->modelClass = $uses[0];
|
||||
|
||||
foreach ($uses as $modelClass) {
|
||||
$modelKey = Inflector::underscore($modelClass);
|
||||
|
||||
if (!class_exists($modelClass)) {
|
||||
App::import('Model', $modelClass);
|
||||
}
|
||||
if (class_exists($modelClass)) {
|
||||
$model =& new $modelClass();
|
||||
$this->modelNames[] = $modelClass;
|
||||
$this->{$modelClass} =& $model;
|
||||
ClassRegistry::addObject($modelKey, $model);
|
||||
if (PHP5) {
|
||||
$this->{$modelClass} = ClassRegistry::init($modelClass);
|
||||
} else {
|
||||
return $this->cakeError('missingModel', array(array('className' => $modelClass)));
|
||||
$this->{$modelClass} =& ClassRegistry::init($modelClass);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -515,8 +515,13 @@ class ControllerTask extends Shell {
|
|||
$enteredController = '';
|
||||
|
||||
while ($enteredController == '') {
|
||||
$enteredController = $this->in('Enter a number from the list above, or type in the name of another controller.');
|
||||
|
||||
$enteredController = $this->in(__("Enter a number from the list above, type in the name of another controller, or 'q' to exit", true), null, 'q');
|
||||
|
||||
if ($enteredController === 'q') {
|
||||
$this->out(__("Exit", true));
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($enteredController == '' || intval($enteredController) > count($controllers)) {
|
||||
$this->out('Error:');
|
||||
$this->out("The Controller name you supplied was empty, or the number \nyou selected was not an option. Please try again.");
|
||||
|
|
|
@ -734,8 +734,13 @@ class ModelTask extends Shell {
|
|||
$enteredModel = '';
|
||||
|
||||
while ($enteredModel == '') {
|
||||
$enteredModel = $this->in(__('Enter a number from the list above, or type in the name of another model.', true));
|
||||
|
||||
$enteredModel = $this->in(__("Enter a number from the list above, type in the name of another model, or 'q' to exit", true), null, 'q');
|
||||
|
||||
if ($enteredModel === 'q') {
|
||||
$this->out(__("Exit", true));
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($enteredModel == '' || intval($enteredModel) > count($this->_modelNames)) {
|
||||
$this->err(__("The model name you supplied was empty, or the number you selected was not an option. Please try again.", true));
|
||||
$enteredModel = '';
|
||||
|
|
Loading…
Reference in a new issue