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


PHP ProgressBar::setFormat方法代码示例

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


在下文中一共展示了ProgressBar::setFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepare

 /**
  * {@inheritdoc}
  */
 public function prepare()
 {
     $this->progress = new ProgressBar($this->output, $this->reader->count());
     $this->progress->setFormat($this->verbosity);
     $this->progress->setRedrawFrequency($this->redrawFrequency);
     $this->progress->start();
 }
开发者ID:megamanhxh,项目名称:data-import,代码行数:10,代码来源:ConsoleProgressWriter.php

示例2: advanceProgress

 /**
  * @param TaskEvent $event
  */
 public function advanceProgress(TaskEvent $event)
 {
     $taskReflection = new ReflectionClass($event->getTask());
     $taskName = $taskReflection->getShortName();
     $this->progressBar->setFormat($this->progressFormat);
     $this->progressBar->setMessage($taskName);
     $this->progressBar->advance();
 }
开发者ID:spinx,项目名称:grumphp,代码行数:11,代码来源:ProgressSubscriber.php

示例3: startProgress

 protected function startProgress($num = 2)
 {
     if (!$this->getOutput()) {
         throw new \Exception('Unable to find console output object.');
     }
     $this->bar = new ProgressBar($this->getOutput(), $num);
     $this->bar->setFormat("%message%\n [%bar%] %percent:3s%% %elapsed% %memory:6s% ");
     $this->bar->start();
 }
开发者ID:humweb,项目名称:slackpipe,代码行数:9,代码来源:ProgressbarTrait.php

示例4: onStartedProviding

 public function onStartedProviding(HasStartedProviding $event)
 {
     $this->output->writeln(sprintf('<info> - Running <comment>%s</comment> provider into <comment>%s/%s</comment></info>', get_class($event->getEntry()->getProvider()), $event->getEntry()->getIndex(), $event->getEntry()->getType()));
     $count = $event->getEntry()->getProvider()->count();
     if (null !== $count) {
         $this->progressBar = new ProgressBar($this->output, $count);
         $this->progressBar->setFormat(self::PROGRESS_BAR_TEMPLATE);
     }
 }
开发者ID:gbprod,项目名称:elasticsearch-dataprovider-bundle,代码行数:9,代码来源:ProvidingProgressBar.php

示例5: getProgressBar

 /**
  * @return \Symfony\Component\Console\Helper\ProgressBar
  */
 private function getProgressBar()
 {
     if ($this->progressBar === null) {
         $this->progressBar = new ProgressBar($this->output, $this->getFileCount());
         $this->progressBar->setFormat("%message%\n%current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%");
         $this->output->writeln('');
     }
     return $this->progressBar;
 }
开发者ID:nochso,项目名称:php-semver-checker,代码行数:12,代码来源:ProgressScanner.php

示例6: 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

示例7: start

 /**
  * {@inheritdoc}
  */
 public function start($count, $label = '')
 {
     $this->count = $count;
     $this->current = 0;
     if ($label) {
         $this->output->writeln($label);
     }
     $this->progress = new ProgressBar($this->output, $count);
     $this->progress->setFormat('very_verbose');
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:13,代码来源:ConsoleProgressHelper.php

示例8: serve

 /**
  * @return int|null|void
  */
 protected function serve()
 {
     $this->progress = new ProgressBar($this->output);
     $this->progress->setFormat('Archiving <cyan>%current%</cyan> files [<green>%bar%</green>] %elapsed:6s% %memory:6s%');
     Grav::instance()['config']->init();
     $destination = $this->input->getArgument('destination') ? $this->input->getArgument('destination') : null;
     $log = JsonFile::instance(Grav::instance()['locator']->findResource("log://backup.log", true, true));
     $backup = ZipBackup::backup($destination, [$this, 'output']);
     $log->content(['time' => time(), 'location' => $backup]);
     $log->save();
     $this->output->writeln('');
     $this->output->writeln('');
 }
开发者ID:dweelie,项目名称:grav,代码行数:16,代码来源:BackupCommand.php

示例9: mainProgressBarAction

 /**
  * @param $total
  * @param OutputInterface $output
  * @param callable        $callback
  */
 public function mainProgressBarAction($total, $output, callable $callback)
 {
     // Перенос строки
     $output->writeln("\n");
     // Инициализируем прогресс бар
     $progress = new ProgressBar($output, $total);
     $progress->setFormat("<info>%message%\n Фильм %current% из %max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%</info>");
     $progress->setMessage('Процесс запущен');
     $progress->start();
     // Инициализируем цикл и выполняем
     $progress->setMessage('В процессе...');
     for ($i = 0; $i < $total; $i++) {
         // Задержка
         sleep(Config::DELAY_BETWEEN_REQUESTS);
         // Выполняем колбэк
         $callback();
         // Передвигаем прогресс бар
         $progress->advance();
     }
     // Завершаем прогресс бар
     $progress->setMessage('Процесс завершен');
     $progress->finish();
     // Перенос строки
     $output->writeln("\n");
 }
开发者ID:REZ1DENT3,项目名称:Kinopoisk2IMDB,代码行数:30,代码来源:RunKinopoisk2Imdb.php

示例10: advance

 /**
  * @param int         $current
  * @param PhpFileInfo $file
  */
 public function advance($current, PhpFileInfo $file)
 {
     if (!$this->verbose) {
         return;
     }
     if (1 === $current) {
         $format = '<info>%message%</info>' . "\n" . $this->label . ': <info>%current%</info>/<info>%max%</info>';
         $this->progressBar->clear();
         $this->progressBar->setFormat($format);
     }
     $message = $file->getRelativePathname();
     $this->progressBar->setMessage($message);
     $this->progressBar->clear();
     $this->progressBar->advance();
     $this->progressBar->display();
 }
开发者ID:Soullivaneuh,项目名称:deprecation-detector,代码行数:20,代码来源:VerboseProgressOutput.php

示例11: execute

 /**
  * Run the command.
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return void
  * @throws Exception
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $serviceName = $input->getArgument('service');
     $service = $this->serviceManager->getService($serviceName);
     $hostProvider = $service->getHostProvider();
     $this->getApplication()->find('listhosts')->run(new ArrayInput(['service' => $serviceName]), $output);
     $output->writeln("");
     $progress = new ProgressBar($output, 5);
     $progress->setFormat(' %current%/%max% [%bar%] %percent:3s%% %message%');
     $progress->setMessage('Checking existing hosts');
     $progress->start();
     $currentHostCount = count($hostProvider->getHostsForService($service));
     if ($service->maxHosts && $currentHostCount >= $service->maxHosts) {
         throw new Exception("There are already {$currentHostCount}/{$service->maxHosts} hosts for {$serviceName}.");
     }
     $newInstance = $currentHostCount + 1;
     $hostname = sprintf($service->hostnameTemplate, $newInstance);
     $host = $hostProvider->launch($hostname, $service->hostDefaults);
     $hostname = $host->getHostname();
     // Just check it set the right name
     $progress->setMessage("Created host " . $hostname . " at " . $hostProvider->getName());
     $progress->advance();
     sleep(5);
     $progress->setMessage("Waiting for " . $hostname . " to be ready");
     $progress->advance();
     while (!$host->isReady()) {
         $lastState = $host->getState();
         $progress->setMessage("Waiting for " . $hostname . " to be ready (Current sate: " . $lastState . ")");
         $progress->display();
         sleep(10);
     }
     if (!empty($service->testUrl)) {
         $progress->setMessage("Testing host's HTTP response");
         $progress->advance();
         do {
             $lastResponse = $host->testHttp($service->testUrl, $service->testUrlHeaders);
             $progress->setMessage("Testing host's HTTP response (Current response: {$lastResponse})");
             $progress->display();
             $lastResponse === 200 || sleep(5);
         } while ($lastResponse !== 200);
     }
     $dnsProvider = $service->getDnsProvider();
     $recordData = [];
     foreach ($host->publicIps as $ip) {
         foreach ($service->dnsRecords as $domain => $domainRecords) {
             foreach ($domainRecords as $record => $recordSettings) {
                 $data = ['domain' => $domain, 'type' => $ip->version === 6 ? 'AAAA' : 'A', 'name' => sprintf($record, $newInstance), 'value' => $ip->ip];
                 $recordData[] = $data + $recordSettings;
             }
         }
     }
     $progress->setMessage("Adding " . count($recordData) . " DNS records to " . $dnsProvider->getName());
     $progress->advance();
     $dnsProvider->addRecords($recordData);
     $progress->setMessage('Done!');
     $progress->finish();
     $output->writeln("");
     $output->writeln("");
     $this->getApplication()->find('listhosts')->run(new ArrayInput(['service' => $serviceName]), $output);
 }
开发者ID:antriver,项目名称:cloud-scaler,代码行数:69,代码来源:ScaleUp.php

示例12: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->title('Exporting databases');
     $io->section('Exporting all databases');
     $strategies = $this->collectorDbStrategy->collectDatabasesStrategies();
     $totalStrategies = count($strategies);
     $io->writeln($totalStrategies . ' strategie(s) found.');
     $progressBar = new ProgressBar($output, $totalStrategies);
     $progressBar->setFormat(self::PROGRESS_BAR_FORMAT);
     $progressBar->setMessage('Beginning backuping');
     $this->eventDispatcher->dispatch(Events::BACKUP_BEGINS, new BackupBeginsEvent($output));
     $progressBar->start();
     $reportContent = new \ArrayObject();
     foreach ($strategies as $strategy) {
         $strategyIdentifier = $strategy->getIdentifier();
         $setProgressBarMessage = function ($message) use($progressBar, $strategyIdentifier) {
             $message = "[{$strategyIdentifier}] {$message}";
             $progressBar->setMessage($message);
             $progressBar->display();
         };
         $exportedFiles = $this->processorDatabaseDumper->dump($strategy, $setProgressBarMessage);
         $reportContent->append("Backuping of the database: {$strategyIdentifier}");
         foreach ($exportedFiles as $file) {
             $filename = $file->getPath();
             $reportContent->append("\t→ {$filename}");
         }
         $progressBar->advance();
     }
     $progressBar->finish();
     $io->newLine(2);
     $io->section('Report');
     $io->text($reportContent->getArrayCopy());
     $this->eventDispatcher->dispatch(Events::BACKUP_ENDS, new BackupEndsEvent($output));
 }
开发者ID:Viscaweb,项目名称:EasyBackups,代码行数:35,代码来源:DatabaseDumperCommand.php

示例13: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->configuration = $this->getHelperSet()->get('configuration')->getConfiguration();
     $this->entityManager = $this->getHelperSet()->get('em')->getEntityManager();
     $this->questionHelper = $this->getHelperSet()->get('question');
     if (!empty($this->configuration['assetsProcessing']['maxPixelSize']) && $this->configuration['assetsProcessing']['maxPixelSize'] > 0) {
         $this->downscaler = new DownscaleImageManager($this->entityManager, null, $this->configuration['assetsProcessing']['driver'], $this->configuration['assetsProcessing']['maxPixelSize']);
         $confirmation = new ConfirmationQuestion('<question>Are you sure to downscale all your image documents to ' . $this->configuration['assetsProcessing']['maxPixelSize'] . 'px?</question>', false);
         if ($this->questionHelper->ask($input, $output, $confirmation)) {
             $documents = $this->entityManager->getRepository('RZ\\Roadiz\\Core\\Entities\\Document')->findBy(['mimeType' => ['image/png', 'image/jpeg', 'image/gif', 'image/tiff'], 'raw' => false]);
             $progress = new ProgressBar($output, count($documents));
             $progress->setFormat('verbose');
             $progress->start();
             foreach ($documents as $document) {
                 $this->downscaler->processDocumentFromExistingRaw($document);
                 $progress->advance();
             }
             $progress->finish();
             $text = PHP_EOL . '<info>Every documents have been downscaled, a raw version has been kept.</info>' . PHP_EOL;
             /*
              * Clear cache documents
              */
             $assetsClearer = new AssetsClearer();
             $assetsClearer->clear();
             $text .= $assetsClearer->getOutput() . PHP_EOL;
         }
     } else {
         $text = '<info>Your configuration is not set for downscaling documents.</info>' . PHP_EOL;
         $text .= 'Add <info>assetsProcessing.maxPixelSize</info> parameter in your <info>config.yml</info> file.' . PHP_EOL;
     }
     $output->writeln($text);
 }
开发者ID:QuangDang212,项目名称:roadiz,代码行数:32,代码来源:DocumentDownscaleCommand.php

示例14: reindex

 private function reindex(string $locale, OutputInterface $output)
 {
     $totalEntities = $this->repository->getTotalCount();
     $iterations = $this->getIterations($totalEntities, $this->batchSize);
     $output->writeln(sprintf('<comment>Total entities:</comment> %s', $totalEntities));
     $output->writeln(sprintf('<comment>Batch size:</comment> %s', $this->batchSize));
     $output->writeln(sprintf('<comment>Iterations:</comment> %s', count($iterations)));
     $output->writeln(sprintf('<comment>Locale:</comment> %s', $locale));
     $output->writeln('<info>Flushing index</info>');
     $this->manager->flushIndex($locale);
     $progress = new ProgressBar($output, $totalEntities);
     $progress->setFormat('verbose');
     $progress->setRedrawFrequency($this->batchSize);
     $progress->start();
     foreach ($iterations as $iteration) {
         $entities = $this->getEntities($iteration);
         foreach ($entities as $entity) {
             $document = $this->type->createDocument($entity, $locale);
             $this->manager->addDocument($document);
             $progress->advance();
         }
     }
     $progress->finish();
     $output->writeln('');
     $output->writeln('<info>Optimizing index</info>');
     $this->manager->optimizeIndex($locale);
 }
开发者ID:WellCommerce,项目名称:SearchBundle,代码行数:27,代码来源:ReindexCommand.php

示例15: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var ImportAddressService $importAddressService */
     $importAddressService = $this->getHelper('container')->getByType('StreetApi\\Services\\ImportAddressService');
     $cityId = $input->getArgument('cityId');
     $xmlFile = simplexml_load_file($importAddressService->getRootDir() . '/../adresy.xml');
     if (!$xmlFile) {
         $output->writeln(PHP_EOL . '<error>Missing source file!</error>');
         return 1;
     }
     try {
         $output->writeLn('<info>Start importing addresses</info>');
         $totalCount = $xmlFile->count();
         $output->writeln(PHP_EOL . PHP_EOL . PHP_EOL . PHP_EOL);
         $progressBar = new ProgressBar($output, $totalCount);
         $progressBar->setFormat('%message%' . PHP_EOL . '%bar% %percent:3s% %' . PHP_EOL . 'count: %current%/%max%' . PHP_EOL . 'time:  %elapsed:6s%/%estimated:-6s%' . PHP_EOL);
         $progressBar->setBarCharacter('<info>■</info>');
         $progressBar->setEmptyBarCharacter(' ');
         $progressBar->setProgressCharacter('');
         $progressBar->setRedrawFrequency(ceil($totalCount / 100));
         $progressBar->start();
         $importAddressService->import($xmlFile, $progressBar, $cityId);
         $output->writeLn(PHP_EOL . '<info>Importing addresses finished</info>');
         return 0;
     } catch (\Exception $e) {
         $output->writeLn('<error>' . $e->getMessage() . '</error>');
         return 1;
     }
 }
开发者ID:neogenia,项目名称:mvcr-street-api,代码行数:29,代码来源:ImportAddressCommand.php


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