本文整理汇总了PHP中Symfony\Component\Console\Helper\ProgressBar::getMaxSteps方法的典型用法代码示例。如果您正苦于以下问题:PHP ProgressBar::getMaxSteps方法的具体用法?PHP ProgressBar::getMaxSteps怎么用?PHP ProgressBar::getMaxSteps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Helper\ProgressBar
的用法示例。
在下文中一共展示了ProgressBar::getMaxSteps方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getProgress
/**
* Get progress bar instance
*
* @param integer $total
*
* @return ProgressBar
*/
public function getProgress($total = null)
{
if (!$this->progress || $this->progress->getMaxSteps() === $this->progress->getProgress()) {
$this->progress = new ProgressBar($this->output, $total);
}
return $this->progress;
}
示例2: finishProgress
/**
* @param RunnerEvent $runnerEvent
*/
public function finishProgress(RunnerEvent $runnerEvent)
{
if ($this->progressBar->getProgress() != $this->progressBar->getMaxSteps()) {
$this->progressBar->setFormat('<fg=red>%message%</fg=red>');
$this->progressBar->setMessage('Aborted ...');
}
$this->progressBar->finish();
$this->output->writeln('');
}
示例3: increment
/**
* {@inheritdoc}
*/
public function increment($increment = 1)
{
if ($this->bar === null) {
return;
}
$this->bar->advance($increment);
if ($this->bar->getProgress() === $this->bar->getMaxSteps()) {
$this->consoleIO->getOutput()->writeln(' - Finished!');
}
}
示例4: bindEventsForUi
/**
* 绑定事件
* @param Runner $runner
* @param OutputInterface $output
*/
protected function bindEventsForUi(Runner $runner, OutputInterface $output)
{
$chain = $runner->getExaminationChain();
$progressBar = new ProgressBar($output, count($chain));
$dispatcher = $runner->getDispatcher();
$dispatcher->bind(Runner::EVENT_RUN, function () use($output, $progressBar) {
$output->writeln("Hi {$this->author}!");
$output->writeln("Runner started and will be performed {$progressBar->getMaxSteps()} tasks");
$output->write(PHP_EOL);
$progressBar->start();
});
//执行新的测试任务
$dispatcher->bind(Runner::EVENT_EXAMINATION_EXECUTE, function (Event $event) use($output, $progressBar) {
$examination = $event->getArgument('examination');
$examination->getReport()->write('_beginTime', microtime(true));
});
//测试任务执行完毕
$dispatcher->bind(Runner::EVENT_EXAMINATION_EXECUTE, function (Event $event) use($output, $progressBar) {
$examination = $event->getArgument('examination');
$examination->getReport()->write('_endTime', microtime(true));
$consume = microtime(true) - $examination->getReport()->read('_beginTime');
$examination->getReport()->write('consume', $consume);
$progressBar->advance(1);
});
$dispatcher->bind(Runner::EVENT_FINISH, function () use($output, $progressBar) {
$progressBar->finish();
$output->writeln(PHP_EOL);
$output->writeln("Runner stop,Generating test report");
});
$dispatcher->bind(Runner::EVENT_FINISH, function () use($runner) {
$this->makeReport($runner);
});
}
示例5: execute
/**
* Executes the current command.
*
* This method is not abstract because you can use this class
* as a concrete class. In this case, instead of defining the
* execute() method, you set the code to execute by passing
* a Closure to the setCode() method.
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return null|int null or 0 if everything went fine, or an error code
*
* @see setCode()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$entity = $input->getArgument('entity');
/** @var EntityManager $entityManager */
$entityManager = $this->getContainer()->get('doctrine.orm.entity_manager');
if ($entity === 'article') {
$output->writeln('<comment>This might take a while.</comment>');
$journals = $entityManager->getRepository('OjsJournalBundle:Journal')->findAll();
$totalProgress = new ProgressBar($output, count($journals));
$totalProgress->setFormat('%current%/%max% [%bar%] %message%');
if ($totalProgress->getMaxSteps() > 0) {
$totalProgress->setMessage('Numerating...');
$totalProgress->start();
}
/** @var Journal $journal */
foreach ($journals as $journal) {
$articles = $entityManager->getRepository('OjsJournalBundle:Article')->findBy(['journal' => $journal]);
$totalProgress->setMessage('Numerating articles of "' . $journal->getTitle() . '"');
foreach ($articles as $article) {
NumeratorHelper::numerateArticle($article, $entityManager);
}
$totalProgress->advance();
}
$totalProgress->finish();
$output->writeln('');
// Necessary, unfortunately.
$output->writeln('<info>Done.</info>');
} else {
if ($entity === 'issue') {
$output->writeln('<comment>This might take a while.</comment>');
$journals = $entityManager->getRepository('OjsJournalBundle:Journal')->findAll();
$totalProgress = new ProgressBar($output, count($journals));
$totalProgress->setFormat('%current%/%max% [%bar%] %message%');
if ($totalProgress->getMaxSteps() > 0) {
$totalProgress->setMessage('Numerating...');
$totalProgress->start();
}
/** @var Journal $journal */
foreach ($journals as $journal) {
$issues = $entityManager->getRepository('OjsJournalBundle:Issue')->findBy(['journal' => $journal]);
$totalProgress->setMessage('Numerating issues of "' . $journal->getTitle() . '"');
foreach ($issues as $issue) {
NumeratorHelper::numerateIssue($issue, $entityManager);
}
$totalProgress->advance();
}
$totalProgress->finish();
$output->writeln('');
// Necessary, unfortunately.
$output->writeln('<info>Done.</info>');
} else {
$output->writeln('<error>This entity is not yet supported.</error>');
}
}
}
示例6:
function it_finishes_progress_early(OutputInterface $output, ProgressBar $progressBar, RunnerEvent $event)
{
$progressBar->getProgress()->willReturn(1);
$progressBar->getMaxSteps()->willReturn(2);
$progressBar->setFormat(Argument::type('string'))->shouldBeCalled();
$progressBar->setMessage(Argument::type('string'))->shouldBeCalled();
$progressBar->setOverwrite(false)->shouldBeCalled();
$progressBar->finish()->shouldBeCalled();
$output->writeln('')->shouldBeCalled();
$this->finishProgress($event);
}
示例7: 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;
}
示例8: testProgressBar
public function testProgressBar()
{
$progressBar = new ProgressBar(new NullOutput());
$output = new InstallOutput(null, $progressBar);
$output->start('Start', 5);
$this->assertEquals(5, $progressBar->getMaxSteps());
$this->assertEquals('Start', $progressBar->getMessage('message'));
$output->step('Step 1');
$this->assertEquals(1, $progressBar->getProgress());
$this->assertEquals('Step 1', $progressBar->getMessage('message'));
$output->end('End');
$this->assertEquals(5, $progressBar->getProgress());
$this->assertEquals('End', $progressBar->getMessage('message'));
}
示例9: bindEventsForUi
/**
* 绑定ui
* @param MagicHand $magicHand
* @param OutputInterface $output
*/
protected function bindEventsForUi(MagicHand $magicHand, OutputInterface $output)
{
$magicHand->getDispatcher()->bind(MagicHand::EVENT_BEGIN, function (Event $event) use($output) {
$images = $event->getArgument('images');
$progressBar = new ProgressBar($output, count($images));
$output->writeln("Magic Hand started and will be performed {$progressBar->getMaxSteps()} images");
$output->write(PHP_EOL);
$progressBar->start();
$this->progressBar = $progressBar;
});
$magicHand->getDispatcher()->bind(MagicHand::EVENT_PROCESS, function (Event $event) use($output) {
$this->progressBar->advance(1);
});
$magicHand->getDispatcher()->bind(MagicHand::EVENT_END, function (Event $event) use($output) {
$this->progressBar->finish();
$output->writeln(PHP_EOL);
$output->writeln("Work ok");
});
}
示例10: reDrawProgressBar
public function reDrawProgressBar()
{
if ($this->progress !== null && $this->progress->getStartTime() !== null && $this->progress->getProgress() !== $this->progress->getMaxSteps() && $this->progresseBar === true) {
$this->progress->display();
}
}