Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allowing controller bake all to use

connections other than default.
  • Loading branch information...
commit 9d405faf8f74db15b273165df5e23b1b55d7f3eb 1 parent d31c43d
@markstory markstory authored
Showing with 9 additions and 3 deletions.
  1. +9 −3 cake/console/libs/tasks/controller.php
View
12 cake/console/libs/tasks/controller.php
@@ -59,6 +59,7 @@ class ControllerTask extends Shell {
*/
function initialize() {
}
+
/**
* Execution method always used for tasks
*
@@ -101,6 +102,7 @@ function execute() {
}
}
}
+
/**
* Bake All the controllers at once. Will only bake controllers for models that exist.
*
@@ -110,6 +112,7 @@ function execute() {
function all() {
$this->interactive = false;
$this->listAll($this->connection, false);
+ ClassRegistry::config('Model', array('ds' => $this->connection));
foreach ($this->__tables as $table) {
$model = $this->_modelName($table);
$controller = $this->_controllerName($model);
@@ -119,6 +122,7 @@ function all() {
}
}
}
+
/**
* Interactive
*
@@ -272,16 +276,17 @@ function _askAboutMethods() {
function bakeActions($controllerName, $admin = null, $wannaUseSession = true) {
$currentModelName = $this->_modelName($controllerName);
if (!App::import('Model', $currentModelName)) {
- $this->err(__('You must have a model for this class to build scaffold methods. Please try again.', true));
- exit;
+ $this->err(__('You must have a model for this class to build basic methods. Please try again.', true));
+ $this->_stop();
}
$actions = null;
- $modelObj =& new $currentModelName();
+ $modelObj =& ClassRegistry::init($currentModelName);
$controllerPath = $this->_controllerPath($controllerName);
$pluralName = $this->_pluralName($currentModelName);
$singularName = Inflector::variable($currentModelName);
$singularHumanName = Inflector::humanize($currentModelName);
$pluralHumanName = Inflector::humanize($controllerName);
+
$actions .= "\n";
$actions .= "\tfunction {$admin}index() {\n";
$actions .= "\t\t\$this->{$currentModelName}->recursive = 0;\n";
@@ -440,6 +445,7 @@ function bake($controllerName, $actions = '', $helpers = null, $components = nul
}
return false;
}
+
/**
* Assembles and writes a unit test file
*
Please sign in to comment.
Something went wrong with that request. Please try again.