Skip to content
Permalink
Browse files

Adding `cake bake model all`.

  • Loading branch information...
markstory committed Apr 28, 2009
1 parent ec18aac commit 798a9d5e43ae81e0b12d8ac6002b172a20ede47b
Showing with 28 additions and 0 deletions.
  1. +28 −0 cake/console/libs/tasks/model.php
@@ -64,6 +64,9 @@ function execute() {
}
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 @@ function execute() {
}
}
}
/**
* 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
*

0 comments on commit 798a9d5

Please sign in to comment.
You can’t perform that action at this time.