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


PHP ProgressBar::clear方法代码示例

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


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

示例1: cleanProgressbar

 private function cleanProgressbar()
 {
     if ($this->progress !== null && $this->progress->getStartTime() !== null) {
         $this->progress->clear();
         $this->output->writeln("");
     }
 }
开发者ID:noikiy,项目名称:php-to-zephir,代码行数:7,代码来源:Logger.php

示例2: cleanProgressbar

 private function cleanProgressbar()
 {
     if ($this->progress !== null && $this->progress->getStartTime() !== null && $this->progress->getProgress() !== $this->progress->getMaxSteps() && $this->progresseBar === true) {
         $this->progress->clear();
         $this->output->write("\r");
     }
 }
开发者ID:woshigehaoren,项目名称:php-to-zephir,代码行数:7,代码来源:Logger.php

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

示例4: end

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

示例5: hideProgressIndicator

 /**
  * @return bool
  */
 public function hideProgressIndicator()
 {
     $result = $this->progressBarDisplayed;
     if ($this->progressIndicatorRunning && $this->progressBarDisplayed) {
         $this->progressBar->clear();
         // Hack: progress indicator does not reset cursor to beginning of line on 'clear'
         $this->output->write("\r");
         $this->progressBarDisplayed = false;
     }
     return $result;
 }
开发者ID:jjok,项目名称:Robo,代码行数:14,代码来源:ProgressIndicator.php

示例6: execute

 /**
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $fileIterator = new File_Iterator_Facade();
     $files = $input->getArgument('target');
     $files = $fileIterator->getFilesAsArray($files, '.php');
     $extractor = new Extractor();
     $results = [];
     $progress = new ProgressBar($output, count($files));
     foreach ($files as $file) {
         $results[$file] = $extractor->file($file);
         $progress->advance();
     }
     $progress->clear();
     $namespaces = [];
     foreach ($results as $file => $result) {
         foreach ($result as $dependency) {
             $namespaces[$dependency][] = $file;
         }
     }
     ksort($namespaces);
     $output->writeln('');
     // line break (due to the progress bar not completely clearing out)
     if ($input->getOption('why')) {
         foreach ($namespaces as $namespace => $files) {
             $output->writeln($namespace);
             foreach ($files as $file) {
                 $output->writeln("\t" . $file);
             }
         }
     } else {
         foreach (array_keys($namespaces) as $namespace) {
             $output->writeln($namespace);
         }
     }
 }
开发者ID:tomzx,项目名称:php-dependency-extractor,代码行数:39,代码来源:ExtractCommand.php

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

示例8: onProgress

 /**
  * @param ProgressEvent $event
  * @param string        $label
  */
 protected function onProgress($event, $label)
 {
     if (0 === $event->getProcessed()) {
         $format = $label . ': <comment>loading %max% files</comment>';
         $this->progressBar->setFormat($format);
         $this->progressBar->start($event->getTotalNumber());
     } elseif ($event->getProcessed() == $event->getTotalNumber()) {
         $this->progressBar->finish();
         $this->output->writeln('');
     } else {
         if (1 === $event->getProcessed()) {
             $format = $label . ': <info>%current%/%max%</info>';
             $this->progressBar->clear();
             $this->progressBar->setFormat($format);
         }
         $this->progressBar->advance();
     }
 }
开发者ID:rnuernberg,项目名称:deprecation-detector,代码行数:22,代码来源:ProgressListener.php

示例9: importCardsJsonFile

 protected function importCardsJsonFile(\SplFileInfo $fileinfo, $locale)
 {
     $cardsData = $this->getDataFromFile($fileinfo);
     $progress = new ProgressBar($this->output, count($cardsData));
     $progress->start();
     foreach ($cardsData as $cardData) {
         $progress->advance();
         $this->updateEntityFromData($locale, 'AppBundle\\Entity\\Card', $cardData, ['code', 'name'], ['flavor', 'traits', 'text']);
     }
     $progress->finish();
     $progress->clear();
     $this->output->write("\n");
 }
开发者ID:stopfstedt,项目名称:thronesdb,代码行数:13,代码来源:ImportTransCommand.php

示例10: execute

 /**
  * @inheritdoc
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Design pattern detector by Jean-François Lépine <https://twitter.com/Halleck45>');
     $output->writeln('');
     $finder = new Finder($input->getOption('extensions'), $input->getOption('excluded-dirs'));
     $files = $finder->find($input->getArgument('path'));
     if (0 == sizeof($files, COUNT_NORMAL)) {
         throw new \LogicException('No file found');
     }
     //
     // 1. Extracting classes
     $output->writeln('<info>Extracting classes</info>');
     $progress = new ProgressBar($output);
     $progress->start(sizeof($files, COUNT_NORMAL));
     $collection = array();
     $tokenizer = new Tokenizer(new CacheMemory());
     $extractor = new Extractor($tokenizer);
     $nbClasses = 0;
     foreach ($files as $k => $filename) {
         $progress->advance();
         $collection[] = $classes = $extractor->extract($filename);
         $nbClasses += sizeof($classes->getClasses());
     }
     $progress->clear();
     $progress->finish();
     // inform user
     $output->writeln('');
     $output->writeln('');
     $output->writeln(sprintf("<info>Found %d classes</info>", $nbClasses));
     //
     // 2. Extracting patterns
     $output->writeln('<info>Extracting design patterns</info>');
     $patterns = array();
     foreach ($collection as $oop) {
         $classes = $oop->getClasses();
         $resolver = new PatternResolver($classes);
         foreach ($classes as $class) {
             $resolvedClass = new ResolvedClass($class);
             $resolver->resolve($resolvedClass);
             if ($resolvedClass->getPatterns()) {
                 $patterns = array_merge($patterns, $resolvedClass->getPatterns());
             }
         }
     }
     // inform user
     $output->writeln(sprintf("<info>Found %d design patterns</info>", sizeof($patterns)));
     $output->writeln();
     foreach ($patterns as $pattern) {
         $output->writeln(sprintf("\t<info>[%s]</info> %s", $pattern->getName(), $pattern->describe()));
     }
 }
开发者ID:Nicofuma,项目名称:DesignPatternDetector,代码行数:54,代码来源:RunPatternCommand.php

示例11: build

 /**
  * Builds a loggerClosure to be called from inside the Provider to update the command
  * line.
  *
  * @param OutputInterface $output
  * @param string          $action
  * @param string          $index
  * @param string          $type
  *
  * @return callable
  */
 public function build(OutputInterface $output, $action, $index, $type)
 {
     if (!class_exists('Symfony\\Component\\Console\\Helper\\ProgressBar') || !is_callable(array('Symfony\\Component\\Console\\Helper\\ProgressBar', 'getProgress'))) {
         return $this->buildLegacy($output, $action, $index, $type);
     }
     $progress = null;
     return function ($increment, $totalObjects, $message = null) use(&$progress, $output, $action, $index, $type) {
         if (null === $progress) {
             $progress = new ProgressBar($output, $totalObjects);
             $progress->start();
         }
         if (null !== $message) {
             $progress->clear();
             $output->writeln(sprintf('<info>%s</info> <error>%s</error>', $action, $message));
             $progress->display();
         }
         $progress->setMessage(sprintf('<info>%s</info> <comment>%s/%s</comment>', $action, $index, $type));
         $progress->advance($increment);
     };
 }
开发者ID:anteros,项目名称:FOSElasticaBundle,代码行数:31,代码来源:ProgressClosureBuilder.php

示例12: set_task_count

 /**
  * {@inheritdoc}
  */
 public function set_task_count($task_count, $restart = false)
 {
     parent::set_task_count($task_count, $restart);
     if ($this->output->getVerbosity() === OutputInterface::VERBOSITY_NORMAL) {
         if ($this->progress_bar !== null) {
             // Symfony's ProgressBar is immutable regarding task_count, so delete the old and create a new one.
             $this->progress_bar->clear();
         } else {
             $this->io->newLine(2);
         }
         $this->progress_bar = $this->io->createProgressBar($task_count);
         $this->progress_bar->setFormat("    %current:3s%/%max:-3s% %bar%  %percent:3s%%\n" . "             %message%\n");
         $this->progress_bar->setBarWidth(60);
         if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
             $this->progress_bar->setEmptyBarCharacter('░');
             // light shade character \u2591
             $this->progress_bar->setProgressCharacter('');
             $this->progress_bar->setBarCharacter('▓');
             // dark shade character \u2593
         }
         $this->progress_bar->setMessage('');
         $this->progress_bar->start();
     }
 }
开发者ID:phpbb,项目名称:phpbb-core,代码行数:27,代码来源:cli_iohandler.php

示例13: waitAndLog

 /**
  * Wait for a single activity to complete, and display the log continuously.
  *
  * @param Activity        $activity
  * @param OutputInterface $output
  * @param string          $success
  * @param string          $failure
  *
  * @return bool
  *   True if the activity succeeded, false otherwise.
  */
 public static function waitAndLog(Activity $activity, OutputInterface $output, $success = null, $failure = null)
 {
     $output->writeln('Waiting for the activity <info>' . $activity->id . '</info> (' . $activity->getDescription() . "):");
     // Initialize a progress bar which will show elapsed time and the
     // activity's state.
     $bar = new ProgressBar($output);
     $bar->setPlaceholderFormatterDefinition('state', function () use($activity) {
         return self::formatState($activity->state);
     });
     $bar->setFormat("  [%bar%] %elapsed:6s% (%state%)");
     $bar->start();
     // Wait for the activity to complete.
     $activity->wait(function () use($bar) {
         $bar->advance();
     }, function ($log) use($output, $bar) {
         // Clear the progress bar and ensure the current line is flushed.
         $bar->clear();
         $output->write($output->isDecorated() ? "\n[1A" : "\n");
         // Display the new log output, with an indent.
         $output->write(preg_replace('/^/m', '    ', $log));
         // Display the progress bar again.
         $bar->advance();
     });
     $bar->finish();
     $output->writeln('');
     // Display the success or failure messages.
     switch ($activity['result']) {
         case Activity::RESULT_SUCCESS:
             $output->writeln($success ?: "Activity <info>{$activity->id}</info> succeeded");
             return true;
         case Activity::RESULT_FAILURE:
             $output->writeln($failure ?: "Activity <error>{$activity->id}</error> failed");
             return false;
     }
     return false;
 }
开发者ID:drewmelck,项目名称:platformsh-cli,代码行数:47,代码来源:ActivityUtil.php

示例14: updateField

 /**
  * For given $contentId in $versionNo updates fields of $fieldTypeIdentifier type.
  *
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @param \Symfony\Component\Console\Helper\ProgressBar $progress
  * @param int|string $contentId
  * @param int $versionNo
  * @param string $fieldTypeIdentifier
  * @param boolean $dryRun
  */
 protected function updateField(OutputInterface $output, ProgressBar $progress, $contentId, $versionNo, $fieldTypeIdentifier, $dryRun)
 {
     $container = $this->getContainer();
     /** @var \eZ\Publish\SPI\FieldType\FieldType $fieldType */
     /** @var \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter $converter */
     /** @var \eZ\Publish\Core\Persistence\Legacy\Content\Gateway $gateway */
     /** @var \eZ\Publish\SPI\Persistence\Content\Handler $contentHandler */
     /** @var \eZ\Publish\API\Repository\ContentService $contentService */
     /** @var \eZ\Publish\API\Repository\ContentTypeService $contentTypeService */
     $fieldType = $container->get("ezpublish.fieldType.{$fieldTypeIdentifier}");
     $converter = $container->get("ezpublish.fieldType.{$fieldTypeIdentifier}.converter");
     $gateway = $container->get("ezpublish.persistence.legacy.content.gateway");
     $contentHandler = $container->get("ezpublish.spi.persistence.legacy.content.handler");
     $contentService = $container->get("ezpublish.api.service.content");
     $contentTypeService = $container->get("ezpublish.api.service.content_type");
     $content = $contentService->loadContent($contentId, null, $versionNo);
     $spiContent = $contentHandler->load($contentId, $versionNo);
     $contentType = $contentTypeService->loadContentType($content->contentInfo->contentTypeId);
     foreach ($content->getFields() as $field) {
         $fieldDefinition = $contentType->getFieldDefinition($field->fieldDefIdentifier);
         // Match API field by field type
         if ($fieldDefinition->fieldTypeIdentifier != $fieldTypeIdentifier) {
             continue;
         }
         foreach ($spiContent->fields as $spiField) {
             // Match SPI field with API field by ID
             if ($spiField->id != $field->id) {
                 continue;
             }
             // Cast API field value to persistence value
             $persistenceValue = $fieldType->toPersistenceValue($field->value);
             if ($persistenceValue->sortKey == $spiField->value->sortKey) {
                 // Assume stored value is correct
                 break;
             }
             if (!$dryRun) {
                 // Create and fill Legacy Storage field value
                 $storageValue = new StorageFieldValue();
                 $converter->toStorageValue($persistenceValue, $storageValue);
                 $gateway->updateField($spiField, $storageValue);
             }
             $progress->clear();
             $output->write("\r");
             $output->writeln("Updated Content " . $content->id . ", version " . $content->versionInfo->versionNo . ", field " . $spiField->id . ": '" . $spiField->value->sortKey . "' => '" . $persistenceValue->sortKey . "'");
             $output->write("\r");
             $progress->display();
             // Continue outer loop
             break;
         }
     }
 }
开发者ID:nlescure,项目名称:ezpublish-kernel,代码行数:61,代码来源:UpdateSortKeysCommand.php

示例15: testMultilineFormat

 public function testMultilineFormat()
 {
     $bar = new ProgressBar($output = $this->getOutputStream(), 3);
     $bar->setFormat("%bar%\nfoobar");
     $bar->start();
     $bar->advance();
     $bar->clear();
     $bar->finish();
     rewind($output->getStream());
     $this->assertEquals($this->generateOutput(">---------------------------\nfoobar") . $this->generateOutput("=========>------------------\nfoobar                      ") . $this->generateOutput("                            \n                            ") . $this->generateOutput("============================\nfoobar                      "), stream_get_contents($output->getStream()));
 }
开发者ID:saj696,项目名称:pipe,代码行数:11,代码来源:ProgressBarTest.php


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