*/ 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.') ->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'Set this parameter to define a connection to use') ->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. The --connection parameter allows you to change the connection to use. The default connection is the active connection (propel.dbal.default_connection). 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->writeSection($output, '[Propel] You are running the command: propel:insert-sql'); if ($input->getOption('verbose')) { $this->additionalPhingArgs[] = 'verbose'; } list($name, $defaultConfig) = $this->getConnection($input, $output); $ret = $this->callPhing('insert-sql', array( 'propel.database.url' => $defaultConfig['connection']['dsn'], 'propel.database.database' => $defaultConfig['adapter'], 'propel.database.user' => $defaultConfig['connection']['user'], 'propel.database.password' => $defaultConfig['connection']['password'], 'propel.schema.dir' => $this->getApplication()->getKernel()->getRootDir() . '/propel/schema/', )); if (true === $ret) { $output->writeln('All SQL statements have been executed.'); } else { $this->writeTaskError($output, 'insert-sql'); } } else { $output->writeln('You have to use --force to execute all SQL statements.'); } } }