diff --git a/console.php b/console.php index b88ae29dcd..9a2f012cb3 100755 --- a/console.php +++ b/console.php @@ -76,6 +76,7 @@ $cli->addCommands( // Chamilo commands. new ChamiloLMS\Command\Template\AsseticDumpCommand(), + new ChamiloLMS\Command\Transaction\ImportToSystemCommand(), new ChamiloLMS\Command\Transaction\SendCommand(), new ChamiloLMS\Command\Transaction\MineduSendCommand(), new ChamiloLMS\Command\Translation\ExportLanguagesCommand(), diff --git a/src/ChamiloLMS/Command/Transaction/ImportToSystemCommand.php b/src/ChamiloLMS/Command/Transaction/ImportToSystemCommand.php new file mode 100644 index 0000000000..82591a6f49 --- /dev/null +++ b/src/ChamiloLMS/Command/Transaction/ImportToSystemCommand.php @@ -0,0 +1,35 @@ +setName('tx:import-to-system') + ->setDescription('Imports transactions on the transaction table to the local system.') + ->addOption('limit', null, InputOption::VALUE_OPTIONAL, 'The maximum number of transactions to import into the system in this operation.', 10); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $tc = new TransactionLogController(); + $limit = (int) $input->getOption('limit'); + if ($limit <= 0) { + $limit = 10; + } + $imported_ids = $tc->importPendingToSystem($limit); + $output->writeln(sprintf('Imported correctly (%d) transactions to the system.', count($imported_ids['success']))); + if (!empty($imported_ids['fail'])) { + $output->writeln(sprintf('The transactions identified by the following ids failed to be imported: (%s)', implode(', ', $imported_ids['fail']))); + return 1; + } + } +}