Adding cake bake model all.

This commit is contained in:
mark_story 2009-04-27 23:15:28 -04:00
parent ec18aac4ab
commit 798a9d5e43

View file

@ -64,6 +64,9 @@ class ModelTask extends Shell {
}
if (!empty($this->args[0])) {
if (strtolower($this->args[0]) == 'all') {
return $this->all();
}
$model = Inflector::camelize($this->args[0]);
if ($this->bake($model)) {
if ($this->_checkUnitTest()) {
@ -72,6 +75,31 @@ class ModelTask extends Shell {
}
}
}
/**
* Bake all models at once.
*
* @return void
**/
function all() {
$ds = 'default';
if (isset($this->params['connection'])) {
$ds = $this->params['connection'];
}
$this->listAll($ds, false);
foreach ($this->__tables as $table) {
$modelClass = Inflector::classify($table);
$this->out(sprintf(__('Baking %s', true), $modelClass));
if (App::import('Model', $modelClass)) {
$object = new $modelClass();
$modelExists = true;
} else {
App::import('Model');
$object = new Model(array('name' => $modelClass, 'ds' => $ds));
}
$this->bake($object, false);
}
}
/**
* Handles interactive baking
*