From 5b15a2ea62132b281c620bccde4c90401b0dc9ba Mon Sep 17 00:00:00 2001 From: "Marc J. Schmidt" Date: Wed, 19 Nov 2014 18:43:54 +0100 Subject: [PATCH] Added --force back to sql:insert command. Made also --sql-dir configurable and changed its default value to %app_dir%/propel/sql like in propelBundle v1. --- Command/SqlInsertCommand.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Command/SqlInsertCommand.php b/Command/SqlInsertCommand.php index 48afa54..081ae0f 100644 --- a/Command/SqlInsertCommand.php +++ b/Command/SqlInsertCommand.php @@ -12,6 +12,7 @@ namespace Propel\PropelBundle\Command; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; /** * @author Kévin Gomez @@ -26,6 +27,8 @@ class SqlInsertCommand extends WrappedCommand $this ->setName('propel:sql:insert') ->setDescription('Insert SQL statements') + ->addOption('force', null, InputOption::VALUE_NONE, 'Set this parameter to execute this action.') + ->addOption('sql-dir', null, InputOption::VALUE_REQUIRED, 'The SQL files directory') ->addOption('connection', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'Connection to use. Example: default, bookstore') ; } @@ -38,14 +41,29 @@ class SqlInsertCommand extends WrappedCommand return new \Propel\Generator\Command\SqlInsertCommand(); } + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + if ($input->getOption('force')) { + parent::execute($input, $output); + } else { + $output->writeln('You have to use --force to execute all SQL statements.'); + return 1; + } + } + /** * {@inheritdoc} */ protected function getSubCommandArguments(InputInterface $input) { + $defaultSqlDir = sprintf('%s/propel/sql', $this->getApplication()->getKernel()->getRootDir()); + return array( '--connection' => $this->getConnections($input->getOption('connection')), - '--sql-dir' => $this->cacheDir, + '--sql-dir' => $input->getOption('sql-dir') ?: $defaultSqlDir, ); } }