* @author William DURAND */ class BuildCommand extends AbstractPropelCommand { /** * @see Command */ protected function configure() { $this ->setDescription('Hub for Propel build commands (Model classes, SQL)') ->setDefinition(array( new InputOption('classes', '', InputOption::VALUE_NONE, 'Build only classes'), new InputOption('sql', '', InputOption::VALUE_NONE, 'Build only SQL'), new InputOption('insert-sql', '', InputOption::VALUE_NONE, 'Build all and insert SQL'), new InputOption('connection', null, InputOption::VALUE_OPTIONAL, 'Set this parameter to define a connection to use') )) ->setName('propel:build'); } /** * @see Command * * @throws \InvalidArgumentException When the target directory does not exist */ protected function execute(InputInterface $input, OutputInterface $output) { if (!$input->getOption('sql')) { $modelCommand = new BuildModelCommand(); $modelCommand->setApplication($this->getApplication()); $modelCommand->execute($input, $output); } if (!$input->getOption('classes')) { $sqlCommand = new BuildSQLCommand(); $sqlCommand->setApplication($this->getApplication()); $sqlCommand->execute($input, $output); } if ($input->getOption('insert-sql')) { $insertCommand = new InsertSqlCommand(); $insertCommand->setApplication($this->getApplication()); // By-pass the '--force' required option $this->addOption('force', '', InputOption::VALUE_NONE, ''); $input->setOption('force', true); $insertCommand->execute($input, $output); } } }