* @author William DURAND */ class BuildCommand extends AbstractCommand { /** * @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')) { $in = new ArrayInput(array( 'command' => 'propel:model:build', '--connection' => $input->getOption('connection') )); $modelCommand = $this->getApplication()->find('propel:model:build'); $res = $modelCommand->run($in, $output); } if (!$input->getOption('classes')) { $in = new ArrayInput(array( 'command' => 'propel:build:sql', '--connection' => $input->getOption('connection'), )); $sqlCommand = $this->getApplication()->find('propel:sql:build'); $sqlCommand->run($in, $output); } if ($input->getOption('insert-sql')) { $in = new ArrayInput(array( 'command' => 'propel:sql:insert', '--connection' => $input->getOption('connection'), '--force' => true, )); $insertCommand = $this->getApplication()->find('propel:sql:insert'); $insertCommand->run($in, $output); } } }