mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 00:48:25 +00:00
refactoring task loading
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5263 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
ddb5524028
commit
ed23e08921
2 changed files with 12 additions and 17 deletions
|
@ -268,12 +268,9 @@ class ShellDispatcher {
|
|||
$this->shellCommand = Inflector::variable($command);
|
||||
$shell = new $this->shellClass($this);
|
||||
$this->shiftArgs();
|
||||
$shell->initialize();
|
||||
$shell->loadTasks();
|
||||
|
||||
|
||||
if($command == 'help') {
|
||||
if(method_exists($shell, 'help')) {
|
||||
$shell->startup();
|
||||
$shell->help();
|
||||
exit();
|
||||
} else {
|
||||
|
@ -281,10 +278,16 @@ class ShellDispatcher {
|
|||
}
|
||||
}
|
||||
|
||||
$task = Inflector::camelize($command);
|
||||
if(in_array($task, $shell->taskNames)) {
|
||||
$shell->initialize();
|
||||
$shell->loadTasks();
|
||||
|
||||
foreach($shell->taskNames as $task) {
|
||||
$shell->{$task}->initialize();
|
||||
$shell->{$task}->loadTasks();
|
||||
}
|
||||
|
||||
$task = Inflector::camelize($command);
|
||||
if(in_array($task, $shell->taskNames)) {
|
||||
$shell->{$task}->startup();
|
||||
$shell->{$task}->execute();
|
||||
return;
|
||||
|
@ -315,7 +318,6 @@ class ShellDispatcher {
|
|||
$shell->startup();
|
||||
$shell->main();
|
||||
} else if($missingCommand && method_exists($shell, 'help')) {
|
||||
$shell->startup();
|
||||
$shell->help();
|
||||
} else if(!$privateMethod && method_exists($shell, $command)) {
|
||||
$shell->startup();
|
||||
|
|
|
@ -59,15 +59,15 @@ class BakeShell extends Shell {
|
|||
switch($classToBake) {
|
||||
case 'M':
|
||||
$invalidSelection = false;
|
||||
$this->__executeTask($this->Model);
|
||||
$this->Model->execute();
|
||||
break;
|
||||
case 'V':
|
||||
$invalidSelection = false;
|
||||
$this->__executeTask($this->View);
|
||||
$this->View->execute();
|
||||
break;
|
||||
case 'C':
|
||||
$invalidSelection = false;
|
||||
$this->__executeTask($this->Controller);
|
||||
$this->Controller->execute();
|
||||
break;
|
||||
default:
|
||||
$this->out('You have made an invalid selection. Please choose a type of class to Bake by entering M, V, or C.');
|
||||
|
@ -75,13 +75,6 @@ class BakeShell extends Shell {
|
|||
$this->hr();
|
||||
$this->main();
|
||||
}
|
||||
|
||||
function __executeTask($task) {
|
||||
$task->initialize();
|
||||
$task->loadTasks();
|
||||
$task->startup();
|
||||
$task->execute();
|
||||
}
|
||||
|
||||
function help() {
|
||||
$this->out('CakePHP Bake:');
|
||||
|
|
Loading…
Add table
Reference in a new issue