Symfony\Component\Console\Helper\ProgressBar::advance PHP Method

advance() public method

Advances the progress output X steps.
public advance ( integer $step = 1 )
$step integer Number of steps to advance
    public function advance($step = 1)
    {
        $this->setProgress($this->step + $step);
    }

Usage Example

コード例 #1
0
ファイル: Watch.php プロジェクト: mglaman/drupalorg-cli
 /**
  * {@inheritdoc}
  *
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $buildId = $this->stdIn->getArgument('build');
     $client = new Client(['base_uri' => 'https://api.travis-ci.org/', 'cookies' => true, 'headers' => ['User-Agent' => 'DrupalOrgCli/0.0.1', 'Accept' => 'application/json', 'Accept-Encoding' => '*']]);
     $build = $this->getBuild($client, $buildId);
     $this->stdOut->writeln("<comment>Watching build {$buildId}</comment>");
     $progress = new ProgressBar($this->stdOut);
     $progress->start();
     if ($build->state == 'finished') {
         $progress->advance();
     } else {
         while ($build->state != 'finished') {
             $progress->advance();
             sleep(60);
             $build = $this->getBuild($client, $buildId);
         }
     }
     $progress->finish();
     $this->sendNotification('TravisCI', "TravisCI build {$buildId} completed");
     $this->stdOut->writeln('');
     $table = new Table($this->stdOut);
     $table->setHeaders(['ID', 'Message', 'Result']);
     if ($build->result == 0) {
         $style = 'info';
         $result = 'pass';
     } elseif ($build->result == 1) {
         $style = 'error';
         $result = 'fail';
     } else {
         $style = 'comment';
         $result = 'pending';
     }
     $table->addRow([$buildId, $build->message, "<{$style}>" . $result . "</{$style}>"]);
     $table->render();
 }
All Usage Examples Of Symfony\Component\Console\Helper\ProgressBar::advance