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:
gwoo 2008-02-06 00:44:34 +00:00
parent 1db0c07852
commit f5de1ac9a2
4 changed files with 41 additions and 18 deletions

View file

@ -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)) {

View file

@ -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;

View file

@ -515,7 +515,12 @@ 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:');

View file

@ -734,7 +734,12 @@ 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));