From 95e4c804a4ee38baa55e7a5234a2f48bad5b1487 Mon Sep 17 00:00:00 2001 From: Leo Date: Wed, 11 May 2016 07:22:34 +0800 Subject: [PATCH] fix "propel:acl:init" command (#418) let "propel:acl:init" command insert sql into database with a "--force" option --- Command/AclInitCommand.php | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/Command/AclInitCommand.php b/Command/AclInitCommand.php index 1c5e043..0009eec 100644 --- a/Command/AclInitCommand.php +++ b/Command/AclInitCommand.php @@ -82,22 +82,28 @@ EOT return 2; } - // insert sql - $sqlInsertCmd = new \Propel\Generator\Command\SqlInsertCommand(); - $sqlInsertArgs = array( - '--connection' => $this->getConnections($input->getOption('connection')), - ); - - if ($this->runCommand($sqlBuildCmd, $sqlBuildArgs, $input, $output) === 0) { - $this->writeSection( - $output, - '1 SQL file has been inserted.' + + if ($input->getOption('force')) { + // insert sql + $sqlInsertCmd = new \Propel\Generator\Command\SqlInsertCommand(); + $sqlInsertArgs = array( + '--connection' => $this->getConnections($input->getOption('connection')), + '--sql-dir' => $this->getCacheDir(), ); - } else { - $this->writeTaskError($output, 'sql:insert'); - return 3; + if ($this->runCommand($sqlInsertCmd, $sqlInsertArgs, $input, $output) === 0) { + $this->writeSection( + $output, + '1 SQL file has been inserted.' + ); + } else { + $this->writeTaskError($output, 'sql:insert'); + + return 3; + } } + + return 0; } /**