From 4fa4d7a8ca4fb7a480f06f5863a2557d8cd267ac Mon Sep 17 00:00:00 2001 From: guilhermeblanco Date: Wed, 2 Sep 2009 02:41:57 +0000 Subject: [PATCH] [2.0] Added validation to RunSqlTask --- .../ORM/Tools/Cli/Tasks/RunSqlTask.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/Doctrine/ORM/Tools/Cli/Tasks/RunSqlTask.php b/lib/Doctrine/ORM/Tools/Cli/Tasks/RunSqlTask.php index 211cd93f5..b644fb983 100644 --- a/lib/Doctrine/ORM/Tools/Cli/Tasks/RunSqlTask.php +++ b/lib/Doctrine/ORM/Tools/Cli/Tasks/RunSqlTask.php @@ -44,6 +44,29 @@ class RunSqlTask extends AbstractTask ->writeln(' --file= | --sql=', 'INFO'); } + /** + * @inheritdoc + */ + public function validate() + { + if ( ! parent::validate()) { + return false; + } + + $args= $this->getArguments(); + + $isSql = isset($args['sql']); + $isFile = isset($args['file']); + + if ( ! ($isSql ^ $isFile)) { + $printer->writeln("One of --sql or --file required, and only one.", 'ERROR'); + return false; + } + + return true; + } + + /** * Executes the task. */