Permalink
Browse files

[Command] Added more options to the 'model:build', 'sql:build' commands

  • Loading branch information...
1 parent d11f304 commit 36eb3f2d8c665968c22afca0d2d6b7c80739a7df @willdurand willdurand committed Dec 21, 2011
@@ -26,6 +26,8 @@
const DEFAULT_PLATFORM = 'MysqlPlatform';
+ const DEFAULT_MYSQL_ENGINE = 'InnoDB';
+
/**
* {@inheritdoc}
*/
@@ -34,6 +36,8 @@ protected function configure()
$this
->addOption('input-dir', null, InputOption::VALUE_REQUIRED, 'The input directory', self::DEFAULT_INPUT_DIRECTORY)
->addOption('platform', null, InputOption::VALUE_REQUIRED, 'The platform', self::DEFAULT_PLATFORM)
+ // MySQL specific
+ ->addOption('mysql-engine', null, InputOption::VALUE_REQUIRED, 'MySQL engine (MyISAM, InnoDB, ...)', self::DEFAULT_MYSQL_ENGINE)
;
}
@@ -40,7 +40,7 @@ class ModelBuild extends AbstractCommand
const DEFAULT_TABLEMAP_BUILDER = '\Propel\Generator\Builder\Om\TableMapBuilder';
- const DEFAULT_PLURALIZER = '\Propel\Generator\Builder\Util\DefaultEnglishPluralizer';
+ const DEFAULT_PLURALIZER = '\Propel\Generator\Builder\Util\StandardEnglishPluralizer';
/**
* {@inheritdoc}
@@ -73,8 +73,16 @@ protected function configure()
'The tablemap class generator name', self::DEFAULT_TABLEMAP_BUILDER)
->addOption('pluralizer-class', null, InputOption::VALUE_REQUIRED,
'The pluralizer class name', self::DEFAULT_PLURALIZER)
- ->addOption('disable-identifier-quoting', null, InputOption::VALUE_NONE,
+ ->addOption('enable-identifier-quoting', null, InputOption::VALUE_NONE,
'Identifier quoting may result in undesired behavior (especially in Postgres)')
+ ->addOption('target-package', null, InputOption::VALUE_REQUIRED,
+ '', '')
+ ->addOption('enable-package-object-model', null, InputOption::VALUE_NONE,
+ '')
+ ->addOption('disable-namespace-auto-package', null, InputOption::VALUE_NONE,
+ 'Disable namespace auto-packaging')
+ ->addOption('base-prefix', null, InputOption::VALUE_REQUIRED,
+ 'Prefix for base classes', 'Base')
->setName('model:build')
->setDescription('Build the model classes based on Propel XML schemas')
;
@@ -98,7 +106,26 @@ protected function execute(InputInterface $input, OutputInterface $output)
'propel.builder.queryinheritancestub.class' => $input->getOption('query-inheritance-stub-class'),
'propel.builder.tablemap.class' => $input->getOption('tablemap-class'),
'propel.builder.pluralizer.class' => $input->getOption('pluralizer-class'),
- 'propel.disableIdentifierQuoting' => $input->getOption('disable-identifier-quoting'),
+ 'propel.disableIdentifierQuoting' => !$input->getOption('enable-identifier-quoting'),
+ 'propel.targetPackage' => $input->getOption('target-package'),
+ 'propel.packageObjectModel' => $input->getOption('enable-package-object-model'),
+ 'propel.namespace.autoPackage' => !$input->getOption('disable-namespace-auto-package'),
+ 'propel.basePrefix' => $input->getOption('base-prefix'),
+ 'propel.addGenericAccessors' => true,
+ 'propel.addGenericMutators' => true,
+ 'propel.addSaveMethod' => true,
+ 'propel.addTimeStamp' => false,
+ 'propel.addValidateMethod' => true,
+ 'propel.addHooks' => true,
+ 'propel.namespace.om' => 'Om',
+ 'propel.namespace.map' => 'Map',
+ 'propel.useLeftJoinsInDoJoinMethods' => true,
+ 'propel.emulateForeignKeyConstraints' => false,
+ 'propel.schema.autoPrefix = false' => false,
+ 'propel.dateTimeClass' => '\DateTime',
+ // MySQL specific
+ 'propel.mysql.tableType' => $input->getOption('mysql-engine'),
+ 'propel.mysql.tableEngineKeyword' => 'ENGINE',
));
$filesystem = new Filesystem();
@@ -28,8 +28,6 @@ class SqlBuild extends AbstractCommand
{
const DEFAULT_OUTPUT_DIRECTORY = 'generated-sql';
- const DEFAULT_MYSQL_ENGINE = 'MyISAM';
-
/**
* {@inheritdoc}
*/
@@ -43,8 +41,6 @@ protected function configure()
->addOption('schema-name', null, InputOption::VALUE_REQUIRED, 'The schema name for RDBMS supporting them', '')
->addOption('encoding', null, InputOption::VALUE_REQUIRED, 'The encoding to use for the database', '')
->addOption('table-prefix', null, InputOption::VALUE_REQUIRED, 'Add a prefix to all the table names in the database', '')
- // MySQL specific
- ->addOption('mysql-engine', null, InputOption::VALUE_REQUIRED, 'MySQL engine (MyISAM, InnoDB, ...)', self::DEFAULT_MYSQL_ENGINE)
->setName('sql:build')
->setDescription('Build SQL files')
;
@@ -56,12 +52,14 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$generatorConfig = new GeneratorConfig(array(
- 'propel.platform.class' => $input->getOption('platform'),
- 'propel.database.schema' => $input->getOption('schema-name'),
- 'propel.database.encoding' => $input->getOption('encoding'),
- 'propel.tablePrefix' => $input->getOption('table-prefix'),
+ 'propel.platform.class' => $input->getOption('platform'),
+ 'propel.database.schema' => $input->getOption('schema-name'),
+ 'propel.database.encoding' => $input->getOption('encoding'),
+ 'propel.tablePrefix' => $input->getOption('table-prefix'),
+ 'propel.useLeftJoinsInDoJoinMethods' => true,
// MySQL specific
- 'propel.mysql.tableType' => $input->getOption('mysql-engine'),
+ 'propel.mysql.tableType' => $input->getOption('mysql-engine'),
+ 'propel.mysql.tableEngineKeyword' => 'ENGINE',
));
$filesystem = new Filesystem();
@@ -279,7 +279,7 @@ protected function loadDataModels()
$this->dataModelDbMap[$ad->getName()] = $ad->getDatabase(null, false)->getName();
}
- if (count($ads) > 1) {
+ if (count($ads) > 1 && $this->getGeneratorConfig()->getBuildProperty('packageObjectModel')) {
$ad = $this->joinDataModels($ads);
$this->dataModels = array($ad);
} else {

0 comments on commit 36eb3f2

Please sign in to comment.