本文整理汇总了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;
}
示例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: 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);
}
示例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'));
}
示例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: reDrawProgressBar
public function reDrawProgressBar()
{
if ($this->progress !== null && $this->progress->getStartTime() !== null && $this->progress->getProgress() !== $this->progress->getMaxSteps() && $this->progresseBar === true) {
$this->progress->display();
}
}
示例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>');
}