/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $manager = new SqlManager(); $configOptions = array(); if ($sqlDir = $input->getOption('sql-dir')) { $configOptions['propel']['paths']['sqlDir'] = $sqlDir; } $generatorConfig = $this->getGeneratorConfig($configOptions, $input); $connections = array(); $optionConnections = $input->getOption('connection'); if (!$optionConnections) { $connections = $generatorConfig->getBuildConnections(); } else { foreach ($optionConnections as $connection) { list($name, $dsn, $infos) = $this->parseConnection($connection); $connections[$name] = array_merge(array('dsn' => $dsn), $infos); } } $manager->setConnections($connections); $manager->setLoggerClosure(function ($message) use($input, $output) { if ($input->getOption('verbose')) { $output->writeln($message); } }); $manager->setWorkingDirectory($generatorConfig->getSection('paths')['sqlDir']); $manager->insertSql(); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $manager = new SqlManager(); if (!$input->hasOption('connection')) { throw new InvalidArgumentException(sprintf('At least one connection is required')); } $connections = array(); foreach ($input->getOption('connection') as $connection) { list($name, $dsn, $infos) = $this->parseConnection($connection); $connections[$name] = array_merge(array('dsn' => $dsn), $infos); } $manager->setConnections($connections); $manager->setLoggerClosure(function ($message) use($input, $output) { if ($input->getOption('verbose')) { $output->writeln($message); } }); $manager->setWorkingDirectory($input->getOption('output-dir')); $manager->insertSql(); }