diff --git a/cake/console/cake.php b/cake/console/cake.php index 8d1de0eff..812b423ce 100644 --- a/cake/console/cake.php +++ b/cake/console/cake.php @@ -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(); diff --git a/cake/console/libs/bake.php b/cake/console/libs/bake.php index bce07bbe7..2ad1dda5f 100644 --- a/cake/console/libs/bake.php +++ b/cake/console/libs/bake.php @@ -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:');