From bd2eb417cf652d97b821da45f6635da57bd654bb Mon Sep 17 00:00:00 2001 From: William DURAND Date: Wed, 2 Feb 2011 19:47:50 +0100 Subject: [PATCH] Added a new command : propel:insert-sql --- Command/InsertSqlCommand.php | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Command/InsertSqlCommand.php diff --git a/Command/InsertSqlCommand.php b/Command/InsertSqlCommand.php new file mode 100644 index 0000000..652a72c --- /dev/null +++ b/Command/InsertSqlCommand.php @@ -0,0 +1,60 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +/** + * InsertSqlCommand. + * + * @author William DURAND + */ +class InsertSqlCommand extends PhingCommand +{ + /** + * @see Command + */ + protected function configure() + { + $this + ->setDescription('Insert SQL for current model') + ->addOption('force', null, InputOption::VALUE_NONE, 'Set this parameter to execute this action.') + ->setHelp(<<propel:insert-sql command connects to the database and executes all SQL statements found in app/propel/sql/*schema.sql. + + php app/console propel:insert-sql + + The --force parameter has to be used to actually insert SQL. + +EOT + ) + ->setName('propel:insert-sql') + ; + } + + /** + * @see Command + * + * @throws \InvalidArgumentException When the target directory does not exist + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + if ($input->getOption('force')) { + $this->callPhing('insert-sql'); + } else { + $output->writeln('You have to use --force to execute all SQL statements.'); + } + } +}