From ed23e08921eeb9cdffbff6f83fcfc0981e98b743 Mon Sep 17 00:00:00 2001 From: gwoo Date: Fri, 8 Jun 2007 07:53:58 +0000 Subject: [PATCH] refactoring task loading git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5263 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/console/cake.php | 16 +++++++++------- cake/console/libs/bake.php | 13 +++---------- 2 files changed, 12 insertions(+), 17 deletions(-) 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:');