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


PHP ProgressBar::finish方法代码示例

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


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

示例1: start

 /**
  * {@inheritdoc}
  */
 public function start()
 {
     $dispatcher = $this->getDispatcher();
     $sourceEvent = new SourcePipelineEvent();
     $sourceEvent->setContext($this->getContext());
     $dispatcher->dispatch($this->getEventName(self::EVENT_SUFFIX_SOURCE), $sourceEvent);
     $this->setContext($sourceEvent->getContext());
     $sources = $sourceEvent->getSources();
     $outputs = [];
     $startEvent = new StartPipelineEvent();
     $startEvent->setContext($this->getContext());
     $startEvent->setItemCount($this->countSourceItems($sources));
     $dispatcher->dispatch($this->getEventName(self::EVENT_SUFFIX_START), $startEvent);
     $this->setContext($startEvent->getContext());
     $this->progressBar && $this->progressBar->start($this->countSourceItems($sources));
     foreach ($sources as $source) {
         foreach ($source as $item) {
             $itemEvent = new ItemPipelineEvent($item);
             $itemEvent->setContext($this->getContext());
             $dispatcher->dispatch($this->getEventName(self::EVENT_SUFFIX_MODIFY), $itemEvent);
             $dispatcher->dispatch($this->getEventName(self::EVENT_SUFFIX_CONSUME), $itemEvent);
             $output = $itemEvent->getOutput();
             if ($output !== null) {
                 $outputs[] = $output;
             }
             $this->setContext($itemEvent->getContext());
             $this->progressBar && $this->progressBar->advance();
         }
     }
     $finishEvent = new FinishPipelineEvent();
     $finishEvent->setContext($this->getContext());
     $dispatcher->dispatch($this->getEventName(self::EVENT_SUFFIX_FINISH), $finishEvent);
     $this->progressBar && $this->progressBar->finish();
     return ['outputs' => $outputs];
 }
开发者ID:asev,项目名称:ConnectionsBundle,代码行数:38,代码来源:Pipeline.php

示例2: finish

 public function finish()
 {
     if ($this->progressBar !== null) {
         $this->progressBar->finish();
         $this->output->writeln('');
     }
 }
开发者ID:gplanchat,项目名称:grenade,代码行数:7,代码来源:GitSubtreeProgressBarHelper.php

示例3: execute

 /**
  * Execute the generator command.
  *
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->themes = $this->loadThemes();
     $this->patterns = $this->loadPatterns();
     $this->setupProgressBar($output);
     $twig = new Twig_Environment(new Twig_Loader_Filesystem(BASE_PATH . '/resources/files'));
     foreach ($this->themes as $theme) {
         $theme->year = date('Y');
         $theme->uuid = Uuid::uuid4()->toString();
         foreach ($this->patterns as $pattern) {
             $this->progress->setMessage("Generating '{$theme->theme->name}' theme for '{$pattern->name}'.");
             foreach ($pattern->files as $source => $destination) {
                 $result = $twig->render($source, (array) $theme);
                 $destination = str_replace('{{theme}}', $theme->theme->slug, $destination);
                 if (count($pattern->files) > 1) {
                     $output = BASE_PATH . "/output/{$pattern->slug}/{$theme->theme->slug}/{$destination}";
                 } else {
                     $output = BASE_PATH . "/output/{$pattern->slug}/{$destination}";
                 }
                 @mkdir(dirname($output), 0777, true);
                 file_put_contents($output, $result);
             }
             $this->progress->advance();
         }
     }
     $this->progress->setMessage("Enjoy the themes!");
     $this->progress->finish();
 }
开发者ID:daylerees,项目名称:rainbow,代码行数:36,代码来源:GenerateCommand.php

示例4: download

 /**
  * Download the file to the specified path
  * @return string path to the downloaded file
  */
 public function download()
 {
     if (!ini_get('allow_url_fopen')) {
         throw new Exception('allow_url_fopen is disabled.');
     }
     // open the temp file for writing
     $fileHandle = fopen($this->path, 'wb');
     if ($fileHandle === false) {
         throw new Exception('Could not open temp file.');
     }
     // download context so we can track download progress
     $downloadContext = stream_context_create(array(), array('notification' => array($this, 'showDownloadProgress')));
     // open the download url for reading
     $downloadHandle = @fopen($this->url, 'rb', false, $downloadContext);
     if ($downloadHandle === false) {
         throw new Exception('Could not download installation file.');
     }
     while (!feof($downloadHandle)) {
         if (fwrite($fileHandle, fread($downloadHandle, 1024)) === false) {
             throw new Exception('Could not write installation file to disk.');
         }
     }
     fclose($downloadHandle);
     fclose($fileHandle);
     if ($this->progressBar) {
         $this->progressBar->finish();
         $this->output->writeln('');
     }
     return $this->path;
 }
开发者ID:mattstauffer,项目名称:craft-cli,代码行数:34,代码来源:BaseDownloader.php

示例5: test

 protected function test($count, $classes, OutputInterface $output)
 {
     $this->table = new Table($output);
     $this->table->setHeaders(array('Implementation', 'Memory', 'Duration'));
     $output->writeln(sprintf('<info>%d elements</info>', $count));
     $this->process = new ProgressBar($output, count($classes));
     $this->process->start();
     foreach ($classes as $class) {
         $shortClass = $class;
         //            if (in_array($class, $blacklist)) {
         //                $this->table->addRow([$class, '--', '--']);
         //                continue;
         //            };
         $path = __DIR__ . '/../../bin/test.php';
         $result = `php {$path} {$class} {$count}`;
         $data = json_decode($result, true);
         if (!$data) {
             echo $result;
         }
         $this->table->addRow([$shortClass, sprintf('%11sb', number_format($data['memory'])), sprintf('%6.4fs', $data['time'])]);
         $this->process->advance();
     }
     $this->process->finish();
     $output->writeln('');
     $this->table->render($output);
 }
开发者ID:Pandahisham,项目名称:topsort.php,代码行数:26,代码来源:BenchmarkCommand.php

示例6: onPostFetch

 /**
  * @param TransportEvent $event
  */
 public function onPostFetch(TransportEvent $event)
 {
     if ($this->progressActive) {
         $this->progress->finish();
         $this->progressActive = false;
     }
     $this->progress->setMessage(sprintf('Saved to <info>%s</info>', $event->getTransport()->getDestination()));
 }
开发者ID:treehouselabs,项目名称:io-bundle,代码行数:11,代码来源:ImportOutputSubscriber.php

示例7: end

 public function end()
 {
     if (!$this->verbose) {
         return;
     }
     $this->progressBar->clear();
     $this->progressBar->finish();
 }
开发者ID:Soullivaneuh,项目名称:deprecation-detector,代码行数:8,代码来源:VerboseProgressOutput.php

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

示例9: fire

 /**
  * {@inheritdoc}
  */
 protected function fire()
 {
     $tasks = $this->craft->tasks->getAllTasks();
     if (!$tasks) {
         $this->info('No pending tasks.');
         return;
     }
     foreach ($tasks as $task) {
         if ($task->status === TaskStatus::Running) {
             if ($this->option('reset-running')) {
                 $this->resetTask($task);
             } else {
                 continue;
             }
         }
         if ($task->status === TaskStatus::Error) {
             if ($this->option('reset-failed')) {
                 $this->resetTask($task);
             } else {
                 continue;
             }
         }
         try {
             $taskRecord = TaskRecord::model()->findById($task->id);
             $taskType = $task->getTaskType();
             if (!$taskType) {
                 throw new Exception('Could not find task type for task ID ' . $task->id);
             }
             $task->totalSteps = $taskType->getTotalSteps();
             $task->status = TaskStatus::Running;
             $progressBar = new ProgressBar($this->output, $task->totalSteps);
             $this->info($task->description);
             for ($step = 0; $step < $task->totalSteps; $step++) {
                 $task->currentStep = $step + 1;
                 $this->craft->tasks->saveTask($task);
                 $result = $taskType->runStep($step);
                 if ($result !== true) {
                     $error = is_string($result) ? $result : 'Unknown error';
                     $progressBar->finish();
                     $this->line('');
                     throw new Exception($error);
                 }
                 $progressBar->setProgress($task->currentStep);
             }
             $taskRecord->deleteNode();
             $progressBar->finish();
             $this->line('');
         } catch (Exception $e) {
             $this->failTask($task);
             $this->error($e->getMessage());
         }
     }
     $this->info('All tasks finished.');
 }
开发者ID:rsanchez,项目名称:craft-cli,代码行数:57,代码来源:RunTasksCommand.php

示例10: execute

 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return null|int null or 0 if everything went fine, or an error code
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $config = Config::getInstance();
     $noProgress = $input->getOption('no-progress');
     $query = $input->getArgument('query');
     $provider = $config->getQuery($query);
     if (empty($provider)) {
         $output->writeln("<error>cannot found query \"{$query}\"</error>");
         $output->writeln("<info>you can execute \"</info>ipv4 edit<info>\" to configure the query</info>");
         return 1;
     }
     $type = $input->getOption('type');
     $filename = $config->getFilename($input->getArgument('filename'));
     $export = ExportQuery::create($type, $filename);
     if (empty($export)) {
         $output->writeln("<error>cannot found export query \"{$type}\"</error>");
         return 2;
     }
     $export->setProviders([$provider]);
     $encoding = $input->getOption('encoding');
     if (!empty($encoding)) {
         $export->setEncoding($encoding);
     }
     $ecdz = $input->getOption('ecdz');
     if ($ecdz && method_exists($export, 'setEcdz')) {
         $export->setEcdz($ecdz);
     }
     $remove_ip_in_recode = $input->getOption('remove-ip-in-recode');
     if ($remove_ip_in_recode && method_exists($export, 'setRemoveIpInRecode')) {
         $export->setRemoveIpInRecode($remove_ip_in_recode);
     }
     $output->writeln("<info>export \"{$query}\" to \"{$type}\" filename \"{$filename}\":</info>");
     if (!$noProgress) {
         $export->init(function ($code, $n) use($output) {
             switch ($code) {
                 case 0:
                     $this->progress = new ProgressBar($output, $n);
                     $this->progress->start();
                     break;
                 case 1:
                     $this->progress->setProgress($n);
                     break;
                 case 2:
                     $this->progress->finish();
                     break;
             }
         });
     } else {
         $export->init();
     }
     $output->writeln('<info> completed!</info>');
     return 0;
 }
开发者ID:larryli,项目名称:ipv4-console,代码行数:58,代码来源:ExportCommand.php

示例11: invoke

 public function invoke(ElasticPopulator $populator)
 {
     $begin = function ($total) {
         $this->bar = new ProgressBar($this->out, $total);
         $this->bar->start();
     };
     $tick = function () {
         $this->bar->advance();
     };
     $rows = $populator->populate($begin, $tick);
     $this->bar->finish();
     $this->out->write("\n");
     $this->out->writeln("<info>Reindexed {$rows} rows</info>");
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:14,代码来源:Populate.php

示例12: output

 /**
  * @param $args
  */
 public function output($args)
 {
     switch ($args['type']) {
         case 'message':
             $this->output->writeln($args['message']);
             break;
         case 'progress':
             if ($args['complete']) {
                 $this->progress->finish();
             } else {
                 $this->progress->advance();
             }
             break;
     }
 }
开发者ID:dweelie,项目名称:grav,代码行数:18,代码来源:BackupCommand.php

示例13: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!Loader::includeModule('search')) {
         throw new BitrixException('Search module is not installed');
     }
     $searchResult = array();
     $bar = new ProgressBar($output, 0);
     do {
         $bar->display();
         $searchResult = \CSearch::ReIndexAll($input->getOption('full'), static::UPDATE_TIME, $searchResult);
         $bar->advance();
         $bar->clear();
         if (is_array($searchResult) && $searchResult['MODULE'] == 'main') {
             list(, $path) = explode("|", $searchResult["ID"], 2);
             $output->writeln("\r       " . $path, OutputInterface::VERBOSITY_VERBOSE);
         }
     } while (is_array($searchResult));
     $bar->finish();
     $bar->clear();
     $output->write("\r");
     if (ModuleManager::isModuleInstalled('socialnetwork')) {
         $output->writeln('<info>The Social Network module needs to be reindexed using the Social Network component in the public section of site.</info>');
     }
     $output->writeln(sprintf('<info>Reindexed</info> %d element%s.', $searchResult, $searchResult > 1 ? 's' : ''));
     return 0;
 }
开发者ID:notamedia,项目名称:console-jedi,代码行数:29,代码来源:ReIndexCommand.php

示例14: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->dm = $this->getContainer()->get('doctrine_mongodb.odm.default_document_manager');
     $allContrats = $this->dm->getRepository('AppBundle:Contrat')->findAll();
     $cptTotal = 0;
     $i = 0;
     $progress = new ProgressBar($output, 100);
     $progress->start();
     $nb = count($allContrats);
     foreach ($allContrats as $contrat) {
         if (count($contrat->getMouvements()) > 0) {
             foreach ($contrat->getMouvements() as $contratMvt) {
                 $contratMvt->setTauxTaxe($contrat->getTva());
             }
             $cptTotal++;
             if ($cptTotal % ($nb / 100) == 0) {
                 $progress->advance();
             }
             if ($i >= 1000) {
                 $this->dm->flush();
                 $i = 0;
             }
             $i++;
         }
     }
     $this->dm->flush();
     $progress->finish();
 }
开发者ID:24eme,项目名称:aurouze,代码行数:28,代码来源:ContratUpdateMvtsCommand.php

示例15: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('desde')) {
         $desde = (int) $input->getOption('desde');
     } else {
         $desde = 0;
     }
     if ($input->getOption('hasta')) {
         $hasta = (int) $input->getOption('hasta');
     } else {
         $hasta = 0;
     }
     $output->writeln('Geocodificando partidas...');
     $cantidadTotal = $hasta - $desde;
     $progress = null;
     $em = $this->getContainer()->get('doctrine')->getManager();
     $Helper = new \Yacare\CatastroBundle\Helper\PartidaHelper($this->getContainer(), $em);
     $Partidas = $em->getRepository('Yacare\\CatastroBundle\\Entity\\Partida')->findBy(array('Ubicacion' => null), array('id' => 'ASC'), $desde ?: null, $cantidadTotal ?: null);
     $progress = new ProgressBar($output, count($Partidas));
     $progress->start();
     foreach ($Partidas as $Partida) {
         $Helper->ObtenerGeoCoding($Partida);
         $progress->advance();
         $em->flush();
         // Dormir entre unos segundos entre consulta y consulta
         sleep(rand(10, 20));
     }
     $em->clear();
     $progress->finish();
     $output->writeln('');
     $output->writeln('Geocodificación terminada, se procesaron ' . count($Partidas) . ' registros.');
 }
开发者ID:Rezequiel,项目名称:yacare,代码行数:32,代码来源:GeoCodificarPartidasCommand.php


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