Skip to content

Commit

Permalink
Adding cake bake model all.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Apr 28, 2009
1 parent ec18aac commit 798a9d5
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions cake/console/libs/tasks/model.php
Expand Up @@ -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()) {
Expand All @@ -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
*
Expand Down

0 comments on commit 798a9d5

Please sign in to comment.