Skip to content

Commit

Permalink
Allowing controller bake all to use
Browse files Browse the repository at this point in the history
connections other than default.
  • Loading branch information
markstory committed May 17, 2009
1 parent d31c43d commit 9d405fa
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cake/console/libs/tasks/controller.php
Expand Up @@ -59,6 +59,7 @@ class ControllerTask extends Shell {
*/ */
function initialize() { function initialize() {
} }

/** /**
* Execution method always used for tasks * Execution method always used for tasks
* *
Expand Down Expand Up @@ -101,6 +102,7 @@ function execute() {
} }
} }
} }

/** /**
* Bake All the controllers at once. Will only bake controllers for models that exist. * Bake All the controllers at once. Will only bake controllers for models that exist.
* *
Expand All @@ -110,6 +112,7 @@ function execute() {
function all() { function all() {
$this->interactive = false; $this->interactive = false;
$this->listAll($this->connection, false); $this->listAll($this->connection, false);
ClassRegistry::config('Model', array('ds' => $this->connection));
foreach ($this->__tables as $table) { foreach ($this->__tables as $table) {
$model = $this->_modelName($table); $model = $this->_modelName($table);
$controller = $this->_controllerName($model); $controller = $this->_controllerName($model);
Expand All @@ -119,6 +122,7 @@ function all() {
} }
} }
} }

/** /**
* Interactive * Interactive
* *
Expand Down Expand Up @@ -272,16 +276,17 @@ function _askAboutMethods() {
function bakeActions($controllerName, $admin = null, $wannaUseSession = true) { function bakeActions($controllerName, $admin = null, $wannaUseSession = true) {
$currentModelName = $this->_modelName($controllerName); $currentModelName = $this->_modelName($controllerName);
if (!App::import('Model', $currentModelName)) { if (!App::import('Model', $currentModelName)) {
$this->err(__('You must have a model for this class to build scaffold methods. Please try again.', true)); $this->err(__('You must have a model for this class to build basic methods. Please try again.', true));
exit; $this->_stop();
} }
$actions = null; $actions = null;
$modelObj =& new $currentModelName(); $modelObj =& ClassRegistry::init($currentModelName);
$controllerPath = $this->_controllerPath($controllerName); $controllerPath = $this->_controllerPath($controllerName);
$pluralName = $this->_pluralName($currentModelName); $pluralName = $this->_pluralName($currentModelName);
$singularName = Inflector::variable($currentModelName); $singularName = Inflector::variable($currentModelName);
$singularHumanName = Inflector::humanize($currentModelName); $singularHumanName = Inflector::humanize($currentModelName);
$pluralHumanName = Inflector::humanize($controllerName); $pluralHumanName = Inflector::humanize($controllerName);

$actions .= "\n"; $actions .= "\n";
$actions .= "\tfunction {$admin}index() {\n"; $actions .= "\tfunction {$admin}index() {\n";
$actions .= "\t\t\$this->{$currentModelName}->recursive = 0;\n"; $actions .= "\t\t\$this->{$currentModelName}->recursive = 0;\n";
Expand Down Expand Up @@ -440,6 +445,7 @@ function bake($controllerName, $actions = '', $helpers = null, $components = nul
} }
return false; return false;
} }

/** /**
* Assembles and writes a unit test file * Assembles and writes a unit test file
* *
Expand Down

0 comments on commit 9d405fa

Please sign in to comment.