|
|
@@ -83,8 +83,12 @@ class FixtureTask extends BakeTask {
|
|
|
))->addOption('plugin', array(
|
|
|
'help' => __d('cake_console', 'CamelCased name of the plugin to bake fixtures for.'),
|
|
|
'short' => 'p',
|
|
|
+ ))->addOption('schema', array(
|
|
|
+ 'help' => __d('cake_console', 'Importing schema for fixtures rather than hardcoding it.'),
|
|
|
+ 'short' => 's',
|
|
|
+ 'boolean' => true
|
|
|
))->addOption('records', array(
|
|
|
- 'help' => __d('cake_console', 'Used with --count and <name>/all commands to pull [n] records from the live tables, where [n] is either --count or the default of 10'),
|
|
|
+ 'help' => __d('cake_console', 'Used with --count and <name>/all commands to pull [n] records from the live tables, where [n] is either --count or the default of 10.'),
|
|
|
'short' => 'r',
|
|
|
'boolean' => true
|
|
|
))->epilog(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.'));
|
|
|
@@ -124,9 +128,14 @@ class FixtureTask extends BakeTask {
|
|
|
$this->interactive = false;
|
|
|
$this->Model->interactive = false;
|
|
|
$tables = $this->Model->listAll($this->connection, false);
|
|
|
+
|
|
|
foreach ($tables as $table) {
|
|
|
$model = $this->_modelName($table);
|
|
|
- $this->bake($model);
|
|
|
+ $importOptions = array();
|
|
|
+ if (!empty($this->params['schema'])) {
|
|
|
+ $importOptions['schema'] = $model;
|
|
|
+ }
|
|
|
+ $this->bake($model, false, $importOptions);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -158,11 +167,20 @@ class FixtureTask extends BakeTask {
|
|
|
*/
|
|
|
public function importOptions($modelName) {
|
|
|
$options = array();
|
|
|
- $doSchema = $this->in(__d('cake_console', 'Would you like to import schema for this fixture?'), array('y', 'n'), 'n');
|
|
|
- if ($doSchema === 'y') {
|
|
|
+
|
|
|
+ if (!empty($this->params['schema'])) {
|
|
|
$options['schema'] = $modelName;
|
|
|
+ } else {
|
|
|
+ $doSchema = $this->in(__d('cake_console', 'Would you like to import schema for this fixture?'), array('y', 'n'), 'n');
|
|
|
+ if ($doSchema === 'y') {
|
|
|
+ $options['schema'] = $modelName;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!empty($this->params['records'])) {
|
|
|
+ $doRecords = 'y';
|
|
|
+ } else {
|
|
|
+ $doRecords = $this->in(__d('cake_console', 'Would you like to use record importing for this fixture?'), array('y', 'n'), 'n');
|
|
|
}
|
|
|
- $doRecords = $this->in(__d('cake_console', 'Would you like to use record importing for this fixture?'), array('y', 'n'), 'n');
|
|
|
if ($doRecords === 'y') {
|
|
|
$options['records'] = true;
|
|
|
}
|