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


PHP ProgressBar::setMessage方法代码示例

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


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

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

示例2: setProgressBar

 /**
  * Set progress bar. Once a progress bar has been set on an invoker, it
  * cannot be undone. Instantiate a new invoker if needed. Sub sequent calls
  * to `Invoker::execute()` will reuse the progress bar object.
  *
  * @param ProgressBar $bar
  * @return Invoker
  */
 public function setProgressBar(ProgressBar $bar)
 {
     // start progress bar
     $this->dispatcher->addListener(Events::INVOKER_START, function (InvokerEvent $event) use($bar) {
         $bar->start($event->getSteps()->getUnits());
     });
     // finish progress bar
     $this->dispatcher->addListener(Events::INVOKER_FINISH, function (InvokerEvent $event) use($bar) {
         $bar->setMessage('Finished: ' . $event->getSteps()->getName());
         $bar->finish();
     });
     // step start
     $this->dispatcher->addListener(Events::STEP_BEFORE_EXECUTE, function (StepEvent $event) use($bar) {
         $bar->setMessage($event->getStep()->getDescription() . '...');
         $bar->display();
     });
     // step finish
     $this->dispatcher->addListener(Events::STEP_AFTER_EXECUTE, function (StepEvent $event) use($bar) {
         $bar->advance($event->getStep()->getTicksRemaining());
     });
     // step tick
     $this->dispatcher->addListener(Events::STEP_TICK, function (StepEvent $event) use($bar) {
         $bar->advance($event->getStep()->getTick());
     });
     return $this;
 }
开发者ID:skymeyer,项目名称:sugardev,代码行数:34,代码来源:Invoker.php

示例3: setupProgressBar

 /**
  * @param OutputInterface $output
  * @param Repository $source
  * @param WritableRepository $destination
  */
 private function setupProgressBar(OutputInterface $output, Repository $source, WritableRepository $destination)
 {
     $this->progress = new ProgressBar($output, count($source));
     $this->progress->setMessage('Generating database...');
     $this->progress->start();
     $destination->attach($this);
 }
开发者ID:nick-jones,项目名称:php-ucd,代码行数:12,代码来源:RepositoryTransferCommand.php

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

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

示例6: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $config = $this->get('config');
     $client = $this->get('client');
     $type = $input->getOption('type');
     if (empty($type)) {
         $type = $config->get('default_type');
     }
     $filter = sprintf('%s is null', self::UNSUBSCRIBE_ATTRIBUTE);
     if (!empty($input->getArgument('filter'))) {
         $filter .= ' AND (' . $input->getArgument('filter') . ')';
     }
     // Total count records with unsubscribe attribute value empty / null.
     $total_count = $this->getEntityCount($type, $filter);
     $output->writeln(sprintf('<info>Found %d records where "%s"</info>', $total_count, $filter));
     // Confirm update.
     $question = new ConfirmationQuestion(sprintf('Update these %d records? [y/n] ', $total_count), false);
     $helper = $this->getHelper('question');
     if (!$helper->ask($input, $output, $question)) {
         exit(0);
     }
     $progress = new ProgressBar($output, $total_count);
     $progress->setFormat(" %current%/%max% [%bar%] %percent:3s%% \n%message%");
     $updateParams = array('type_name' => $type, 'attributes' => array(self::UNSUBSCRIBE_ATTRIBUTE => ''));
     $succeed = 0;
     $failed = 0;
     $offset = 0;
     $records = $this->retrieveRecords($this->getQueryParams($offset, $type, $filter));
     if (empty($records)) {
         $output->write('No records to update.');
         exit(0);
     }
     $progress->setMessage('Retrieving records...');
     $progress->start();
     while (!empty($records)) {
         foreach ($records as $record) {
             $updateParams['attributes'][self::UNSUBSCRIBE_ATTRIBUTE] = sha1($record['uuid'] . $record['created']);
             $progress->setMessage(sprintf('Update record with id %s', $record['id']));
             $result = $client->api('entity')->updateById($record['id'], $updateParams);
             if ('ok' === strtolower($result['stat'])) {
                 $succeed++;
             } else {
                 $failed++;
             }
             $progress->advance();
         }
         $offset += sizeof($records);
         $progress->setMessage('Retrieving records...');
         $records = $this->retrieveRecords($this->getQueryParams($offset, $type, $filter));
     }
     if ($failed > 0) {
         $progress->setMessage(sprintf('<info>%d</info> records are successfully updated, but<error>%d</error> records are failed to update. Please try run this command again.', $succeed, $failed));
     } else {
         $progress->setMessage(sprintf('<info>%d</info> records are successfully updated.', $succeed));
     }
     $progress->finish();
     exit($failed > 0 ? 1 : 0);
 }
开发者ID:xwp,项目名称:janrain-cli-tools,代码行数:58,代码来源:EntityFillUnsubKeyCommand.php

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

示例8: log

 /**
  * Log
  *
  * @param string $message
  */
 public function log($message)
 {
     if ($this->progress) {
         $this->progress->setMessage($message);
         $this->logs[] = $message;
     } else {
         $this->output->writeLn($message);
     }
 }
开发者ID:phpillip,项目名称:phpillip,代码行数:14,代码来源:Logger.php

示例9: 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>');
         }
     }
 }
开发者ID:beyzakokcan,项目名称:ojs,代码行数:70,代码来源:NumerateCommand.php

示例10: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $defaultEntityManager = $this->getContainer()->get('doctrine.orm.default_entity_manager');
     $legacyEntityManager = $this->getContainer()->get('doctrine.orm.legacy_entity_manager');
     $legacyCommentsRepository = $legacyEntityManager->getRepository('LegacyBundle:Comment');
     $legacyParameterRepository = $legacyEntityManager->getRepository('LegacyBundle:Parameter');
     $authorRepository = $defaultEntityManager->getRepository('AppBundle:Author');
     $mentionRepository = $defaultEntityManager->getRepository('AppBundle:Mention');
     $legacyComments = $legacyCommentsRepository->findAll();
     $progress = new ProgressBar($output, count($legacyComments));
     $progress->start();
     $progress->setFormat(' %current%/%max% [%bar%] %percent:3s%% %message%');
     $progress->setMessage('Copying legacy data');
     foreach ($legacyComments as $legacyComment) {
         $userId = $legacyComment->getUser()->getId();
         $author = $authorRepository->findOneBy(['userId' => $userId]);
         if (null === $author) {
             $author = new Author();
             $author->setUserId($legacyComment->getUser()->getId());
             $author->setUsername($legacyComment->getUser()->getUsername());
             $avatarParameter = $legacyParameterRepository->findOneBy(['userId' => $legacyComment->getUser()->getId(), 'parameterId' => 4]);
             if (null !== $avatarParameter) {
                 $author->setAvatarFilename($avatarParameter->getValue());
             }
             $defaultEntityManager->persist($author);
             $defaultEntityManager->flush($author);
         }
         $comment = new Comment();
         $comment->setId($legacyComment->getId());
         $comment->setPostId($legacyComment->getPostId());
         $comment->setContent($legacyComment->getContent());
         $comment->setCreatedAt($legacyComment->getCreatedAt());
         $comment->setActive($legacyComment->getActive());
         $comment->setAuthor($author);
         foreach ($legacyComment->getMentions() as $legacyMention) {
             $mention = $mentionRepository->findOneBy(['userId' => $legacyMention->getUser()->getId()]);
             if (null === $mention) {
                 $mention = new Mention();
                 $mention->setUserId($legacyMention->getUser()->getId());
                 $mention->setUsername($legacyMention->getUser()->getUsername());
                 $defaultEntityManager->persist($mention);
                 $defaultEntityManager->flush($mention);
             }
             $comment->addMention($mention);
         }
         $defaultEntityManager->persist($comment);
         $progress->advance();
     }
     $defaultEntityManager->flush();
     $progress->setMessage('Data has been copied');
     $progress->finish();
     $output->writeln('');
 }
开发者ID:microservices-playground,项目名称:api-comments,代码行数:53,代码来源:LegacyDataCopyFromLegacyDbCommand.php

示例11: onStatus

 /**
  * @param array $data
  */
 protected function onStatus(array $data)
 {
     if (isset($data['current'])) {
         $this->progress->setCurrent((int) $data['current']);
         unset($data['current']);
     } else {
         $this->progress->advance();
     }
     foreach ($data as $key => $value) {
         $this->progress->setMessage($value, $key);
     }
 }
开发者ID:flamecore,项目名称:seabreeze,代码行数:15,代码来源:ConsoleProgressResponder.php

示例12: runProcess

 /**
  * Run a terminal command
  * @param  [array]         $command  [description]
  * @param  [path]          $directory [description]
  * @param  OutputInterface $output    [description]
  * @return [void]                     [description]
  */
 private function runProcess($command, $directory, $output, $alias)
 {
     $output->writeln('');
     if (is_array($command['line'])) {
         $commandLine = implode(' && ', $command['line']);
     } else {
         $commandLine = $command['line'];
     }
     $process = new Process($commandLine, $directory);
     $process->setTimeout(7600);
     $process->start();
     if ($output->isVerbose()) {
         $process->wait(function ($type, $buffer) {
             echo $buffer;
         });
     } else {
         $progress = new ProgressBar($output);
         $progress->setFormat("<comment>%message%</comment> [%bar%]");
         $progress->setMessage($command['title']);
         $progress->start();
         $progress->setRedrawFrequency(10000);
         while ($process->isRunning()) {
             $progress->advance();
         }
         $progress->finish();
         $progress->clear();
     }
     $output->writeln('');
     $output->write('<comment>' . $command['title'] . ' </comment><info>√ done</info>');
 }
开发者ID:nobox,项目名称:nobox-laravel-installer,代码行数:37,代码来源:ProcessHelper.php

示例13: createDojo

 /**
  * Shoot the create dojo command into the command bus
  *
  * @param $externalDojo
  */
 private function createDojo($externalDojo)
 {
     $this->progressBar->setMessage('Creating new dojo');
     $this->commandBus->handle($externalDojo);
     $this->progressBar->advance();
     $this->countNew++;
 }
开发者ID:CoderDojoNederland,项目名称:Website,代码行数:12,代码来源:SyncDojoService.php

示例14: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $desde = (int) $input->getArgument('desde');
     $cantidad = 100;
     $progress = null;
     $importador = new ImportadorAgentes($this->getContainer(), $this->getContainer()->get('doctrine')->getManager());
     $importador->Inicializar();
     $progress = new ProgressBar($output, $importador->ObtenerCantidadTotal());
     $progress->setRedrawFrequency(1);
     $progress->setMessage('Importando agentes...');
     $progress->start();
     $ResultadoFinal = new ResultadoImportacion($importador);
     while (true) {
         $resultado = $importador->Importar($desde, $cantidad);
         $ResultadoFinal->AgregarContadoresLote($resultado);
         if (!$resultado->HayMasRegistros()) {
             break;
         }
         $desde += $cantidad;
         $progress->advance($cantidad);
     }
     $progress->finish();
     $output->writeln('');
     $output->writeln(' Se importaron   ' . $ResultadoFinal->RegistrosNuevos . ' registros nuevos.');
     $output->writeln(' Se actualizaron ' . $ResultadoFinal->RegistrosActualizados . ' registros.');
     $output->writeln(' Se ignoraron    ' . $ResultadoFinal->RegistrosIgnorados . ' registros.');
     $output->writeln('Importación finalizada, se procesaron ' . $ResultadoFinal->TotalRegistrosProcesados() . ' registros.');
 }
开发者ID:Drake86cnf,项目名称:yacare,代码行数:28,代码来源:ImportarAgentesCommand.php

示例15: getRegions

 /**
  * Get all available regions.
  * @return mixed|null
  */
 protected function getRegions()
 {
     $this->progress->setMessage("Fetching regions...");
     $this->progress->advance();
     $ec2client = new Ec2Client(['version' => 'latest', 'region' => getenv('AWS_DEFAULT_REGION')]);
     return $ec2client->describeRegions()->search('Regions[].RegionName');
 }
开发者ID:michalvlcek,项目名称:aws-commands,代码行数:11,代码来源:EC2HostsCommand.php


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