/**
* Progress wrapper (if use stepmode).
*
* @param string $name
* @param int $total
* @param int $stepSize
* @param \Closure $onStart
* @param \Closure $onStepMode
* @param \Closure $onFinish
*/
protected function _progressWrap($name, $total, $stepSize, $onStart, $onStepMode, $onFinish)
{
$_this = $this;
$step = $this->_getOpt('step');
$profile = $this->_getOpt('profile');
$stepMode = $this->_getOpt('stepmode');
$isFinished = false;
if ($stepMode) {
if ($step >= 0) {
$onStepMode($step);
} else {
$this->_progressBar($name, $total, $stepSize, function ($currentStep) use($profile, $total, $_this, $name) {
$phpBin = Env::getBinary();
$binPath = './' . FS::getRelative($_SERVER['SCRIPT_FILENAME'], JPATH_ROOT, '/');
$options = array('profile' => $profile, 'step' => (int) $currentStep, 'stepmode' => '', 'q' => '');
$command = $phpBin . ' ' . $binPath . ' ' . $name;
$result = Cli::exec($command, $options, JPATH_ROOT, false);
if (0 && $this->_isDebug()) {
$_this->_($result);
}
return $currentStep <= $total;
});
$isFinished = true;
}
} else {
$isFinished = $onStart();
}
$onFinish($isFinished);
}