mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-12 06:56:24 +00:00
Adding cake bake model all
.
This commit is contained in:
parent
ec18aac4ab
commit
798a9d5e43
1 changed files with 28 additions and 0 deletions
|
@ -64,6 +64,9 @@ class ModelTask extends Shell {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($this->args[0])) {
|
if (!empty($this->args[0])) {
|
||||||
|
if (strtolower($this->args[0]) == 'all') {
|
||||||
|
return $this->all();
|
||||||
|
}
|
||||||
$model = Inflector::camelize($this->args[0]);
|
$model = Inflector::camelize($this->args[0]);
|
||||||
if ($this->bake($model)) {
|
if ($this->bake($model)) {
|
||||||
if ($this->_checkUnitTest()) {
|
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
|
* Handles interactive baking
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue