/** * Executes the current command. * * @param InputInterface $input * @param OutputInterface $output * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $this->_executePrepare($input, $output); $this->_init(); $this->_setupConfigure(); $stepMode = $this->_getOpt('stepmode'); $profileName = $this->_getOpt('profile'); $config = $this->_jbconfig->getList('export.items'); $stepSize = (int) $this->_config->find('params.step_limit', '100'); $totalItems = $this->_getTotal(); $this->_showProfiler('CSV Export - prepared'); $this->_('Step size: ' . $stepSize, 'Info'); $this->_('Total items: ' . $totalItems, 'Info'); $this->_('Step mode: ' . ($stepMode ? 'on' : 'off'), 'Info'); $this->_progressWrap($this->_commandName, $totalItems, $stepSize, function () use($config, $totalItems, $stepSize) { $this->_jbexport->clean(); $this->_progressBar($this->_commandName, $totalItems, $stepSize, function ($currentStep) use($config) { $this->_toCSV($currentStep); }); return true; }, function ($step) use($config) { $this->_toCSV($step); }, function ($isFinished) use($config, $profileName) { if ($isFinished && ($compressFiles = $this->_jbexport->splitFiles())) { $exportPath = $this->_jbpath->sysPath('tmp', '/' . \JBExportHelper::EXPORT_PATH); // Move CSV file to config path. foreach ($compressFiles as $file) { $fileName = basename($file); $dir = JBZOO_CLI_JOOMLA_ROOT . '/' . $config->get('file_path'); $newFile = FS::clean($dir . '/' . $profileName . '-' . $fileName, '/'); \JFile::move($file, $newFile); $this->_('CSV File: ' . $newFile, 'Info'); } // Delete export tmp folder. if (\JFolder::exists($exportPath)) { \JFolder::delete($exportPath); } } $this->_showProfiler('Export - finished'); }); }