当前位置: 首页>>代码示例>>PHP>>正文


PHP ProgressBar::getProgress方法代码示例

本文整理汇总了PHP中Symfony\Component\Console\Helper\ProgressBar::getProgress方法的典型用法代码示例。如果您正苦于以下问题:PHP ProgressBar::getProgress方法的具体用法?PHP ProgressBar::getProgress怎么用?PHP ProgressBar::getProgress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Console\Helper\ProgressBar的用法示例。


在下文中一共展示了ProgressBar::getProgress方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
 }
开发者ID:phpillip,项目名称:phpillip,代码行数:14,代码来源:Logger.php

示例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('');
 }
开发者ID:phpro,项目名称:grumphp,代码行数:12,代码来源:ProgressSubscriber.php

示例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!');
     }
 }
开发者ID:apigen,项目名称:apigen,代码行数:13,代码来源:ProgressBar.php

示例4: 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);
 }
开发者ID:phpstan,项目名称:phpstan,代码行数:16,代码来源:ErrorsConsoleStyle.php

示例5: 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'));
 }
开发者ID:gjb2048,项目名称:moodle-plugin-ci,代码行数:14,代码来源:InstallOutputTest.php

示例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);
 }
开发者ID:Big-Shark,项目名称:grumphp,代码行数:11,代码来源:ProgressSubscriberSpec.php

示例7: reDrawProgressBar

 public function reDrawProgressBar()
 {
     if ($this->progress !== null && $this->progress->getStartTime() !== null && $this->progress->getProgress() !== $this->progress->getMaxSteps() && $this->progresseBar === true) {
         $this->progress->display();
     }
 }
开发者ID:woshigehaoren,项目名称:php-to-zephir,代码行数:6,代码来源:Logger.php

示例8: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $file = $input->getArgument('file');
     $fileReal = realpath($file);
     $output->write('<info>Checking if file</info> ' . $file . ' <info>exits...</info> ');
     if (!$this->getContainer()->get('filesystem')->exists($fileReal)) {
         $output->writeln('<error> File not found! </error>');
         return;
     }
     $output->writeln('<info>File found!</info>');
     mb_internal_encoding('UTF-8');
     $encodingList = mb_detect_order();
     if (!in_array('ISO-8859-1', $encodingList)) {
         array_push($encodingList, 'ISO-8859-1');
         mb_detect_order($encodingList);
     }
     $fileEncoding = mb_detect_encoding($fileContents = file_get_contents($file));
     $output->writeln('<info>Opening file:</info> ' . $fileReal . '');
     $fileContentArray = explode("\n", $fileContents);
     $output->writeln('<info>Found</info> ' . ($lines = count($fileContentArray) . ' <info>lines in the file.</info>'));
     $questionHelper = $this->getHelper('question');
     $output->writeln('');
     if (!$questionHelper->ask($input, $output, new ConfirmationQuestion('<question>Do you confirm deleting all entries? (Y/n)</question> ', true))) {
         $output->writeln('');
         $output->writeln('<error>                                                     </error>');
         $output->writeln('<error>  Aborting, because merging is not yet implemented!  </error>');
         $output->writeln('<error>                                                     </error>');
         return;
     }
     $output->writeln('');
     $doctrine = $this->getContainer()->get('doctrine');
     $entityManger = $doctrine->getManager();
     $validator = $this->getContainer()->get('validator');
     $deletedRows = $entityManger->createQuery('DELETE FROM ChrKo\\Bundle\\GermanCentralBankBundle\\Entity\\Bank b')->execute();
     $output->writeln('<info>Deleted </info>' . $deletedRows . '<info> Rows!</info>');
     $output->writeln('');
     if (!$questionHelper->ask($input, $output, new ConfirmationQuestion('<question>Do you want to proceed and import? (Y/n)</question> '))) {
         $output->writeln('');
         $output->writeln('<error>             </error>');
         $output->writeln('<error>  Aborting.  </error>');
         $output->writeln('<error>             </error>');
     }
     $output->writeln('');
     $map = ['bankNumber' => [0, 8], 'attribute' => [8, 1], 'name' => [9, 58], 'zipCode' => [67, 5], 'city' => [72, 35], 'shortname' => [107, 27], 'pan' => [134, 5], 'bic' => [139, 11], 'checkDigitPlanCalculationMethod' => [150, 2], 'recordNumber' => [152, 6], 'modificationIdentifier' => [158, 1], 'bankNumberDeletion' => [159, 1], 'successorBankNumber' => [160, 8]];
     $progressBar = new ProgressBar($output);
     $progressBar->setRedrawFrequency($redrawFrequency = 100);
     $progressBar->start($lines);
     $validationErrors = [];
     foreach ($fileContentArray as $row => $line) {
         $line = trim($line);
         if (empty($line)) {
             continue;
         }
         $bank = new Bank();
         if ($fileEncoding != mb_internal_encoding()) {
             $line = mb_convert_encoding($line, mb_internal_encoding(), $fileEncoding);
         }
         foreach ($map as $fieldName => $substr) {
             $method = 'set' . ucfirst($fieldName);
             $bank->{$method}(trim(mb_substr($line, $substr[0], $substr[1])));
         }
         $errors = $validator->validate($bank);
         if (count($errors) > 0) {
             $validationErrors[] = (string) $errors;
             $validationErrors[] = $row . $line;
         } else {
             $entityManger->persist($bank);
         }
         if ($progressBar->getProgress() % $redrawFrequency == 0) {
             $entityManger->flush();
             $entityManger->clear();
         }
         $progressBar->advance();
     }
     $progressBar->finish();
     $entityManger->flush();
     $entityManger->clear();
     $output->writeln('');
     $output->write('<error>');
     dump($validationErrors);
     $output->writeln('</error>');
 }
开发者ID:chrko,项目名称:german-central-bank-bundle,代码行数:82,代码来源:ImportCommand.php


注:本文中的Symfony\Component\Console\Helper\ProgressBar::getProgress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。