本文整理汇总了PHP中Symfony\Component\Console\Helper\ProgressBar::getStartTime方法的典型用法代码示例。如果您正苦于以下问题:PHP ProgressBar::getStartTime方法的具体用法?PHP ProgressBar::getStartTime怎么用?PHP ProgressBar::getStartTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Helper\ProgressBar
的用法示例。
在下文中一共展示了ProgressBar::getStartTime方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: progressAdvance
/**
* @phpcsSuppress SlevomatCodingStandard.Typehints.TypeHintDeclaration.missingParameterTypeHint
* @param int $step
*/
public function progressAdvance($step = 1)
{
if ($this->output->isDecorated() && $step > 0) {
$stepTime = (time() - $this->progressBar->getStartTime()) / $step;
if ($stepTime > 0 && $stepTime < 1) {
$this->progressBar->setRedrawFrequency(1 / $stepTime);
} else {
$this->progressBar->setRedrawFrequency(1);
}
}
$this->progressBar->setProgress($this->progressBar->getProgress() + $step);
}
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$pBar = new ProgressBar($output, 10);
$pBar->start();
$showOutput = false;
try {
$sugarKernel = new SugarKernel('cli', 'dev', false);
$sugarKernel->boot();
} catch (\Exception $e) {
$output->writeln($e->getMessage());
}
$pBar->advance(2);
/** @var \User $user */
$user = $sugarKernel->getG('current_user');
$user->getSystemUser();
$modules = $sugarKernel->getG('mod_strings');
$pBar->advance();
$qrr = new Qrr();
if ($input->getOption('yell')) {
$showOutput = true;
$output->writeln('QRR output: ');
}
$qrr->repairAndClearAll(['clearAll'], [$modules['LBL_ALL_MODULES']], true, $showOutput);
$pBar->advance(5);
$sugarKernel->shutdown();
$pBar->finish();
$elapsed = time() - $pBar->getStartTime();
$output->writeln(' ');
$output->writeln(" Executed in: {$elapsed} s");
}
示例3: download
/**
* @param \FlickrDownloadr\Photo\Photo $photo
* @param string $filename
* @param string $dirname
* @return int Number of bytes that were written to the file, or FALSE on failure
*/
public function download(Photo $photo, $filename, $dirname)
{
$url = $photo->getUrl();
if ($this->dryRun) {
return 0;
}
\Nette\Utils\FileSystem::createDir($dirname . '/' . dirname($filename));
$this->setupProgressBar();
$ctx = stream_context_create();
stream_context_set_params($ctx, array("notification" => $this->getNotificationCallback($filename)));
$bytes = file_put_contents($dirname . '/' . $filename, fopen($url, 'r', FALSE, $ctx));
if ($bytes === FALSE) {
$this->progress->setMessage('<error>Error!</error>', 'final_report');
} else {
list($time, $size, $speed) = $this->getFinalStats($this->progress->getMaxSteps(), $this->progress->getStartTime());
$this->progress->setMessage('<comment>[' . $size . ' in ' . $time . ' (' . $speed . ')]</comment>', 'final_report');
$this->progress->setFormat('%message% %final_report%' . "\n");
}
$this->progress->finish();
$this->output->writeln('');
return $bytes;
}
示例4: testSetCurrentBeforeStarting
/**
*/
public function testSetCurrentBeforeStarting()
{
$bar = new ProgressBar($this->getOutputStream());
$bar->setProgress(15);
$this->assertNotNull($bar->getStartTime());
}
示例5: reDrawProgressBar
public function reDrawProgressBar()
{
if ($this->progress !== null && $this->progress->getStartTime() !== null) {
$this->progress->display();
}
}
示例6: reDrawProgressBar
public function reDrawProgressBar()
{
if ($this->progress !== null && $this->progress->getStartTime() !== null && $this->progress->getProgress() !== $this->progress->getMaxSteps() && $this->progresseBar === true) {
$this->progress->display();
}
}