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


PHP ProgressBar::setOverwrite方法代码示例

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


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

示例1: __construct

 /**
  * @param OutputInterface  $output
  * @param ProgressBar $progressBar
  */
 public function __construct(OutputInterface $output, ProgressBar $progressBar)
 {
     $this->output = $output;
     $this->progressBar = $progressBar ?: new ProgressBar($output);
     $this->progressBar->setOverwrite(false);
     $this->progressFormat = "<fg=yellow>Running task %current%/%max%:</fg=yellow> %message%";
 }
开发者ID:phpro,项目名称:grumphp,代码行数:11,代码来源:ProgressSubscriber.php

示例2:

 function it_finishes_progress(OutputInterface $output, ProgressBar $progressBar, RunnerEvent $event)
 {
     $progressBar->setOverwrite(false)->shouldBeCalled();
     $progressBar->finish()->shouldBeCalled();
     $output->writeln('')->shouldBeCalled();
     $this->finishProgress($event);
 }
开发者ID:spinx,项目名称:grumphp,代码行数:7,代码来源:ProgressSubscriberSpec.php

示例3: start

 /**
  * @param int $max
  * @param bool $forceLogLevel
  * @return void
  */
 public function start($max, $forceLogLevel = false)
 {
     if ($this->canRun($forceLogLevel)) {
         echo PHP_EOL;
         $max = $max == 0 ? 1 : $max;
         $this->progressBar->start($max);
         $this->progressBar->setOverwrite(true);
     }
 }
开发者ID:Mohitsahu123,项目名称:data-migration-tool-ce,代码行数:14,代码来源:LogLevelProcessor.php

示例4:

 function it_finishes_progress_early(OutputInterface $output, ProgressBar $progressBar, RunnerEvent $event)
 {
     $progressBar->getProgress()->willReturn(1);
     $progressBar->getMaxSteps()->willReturn(2);
     $progressBar->setFormat(Argument::type('string'))->shouldBeCalled();
     $progressBar->setMessage(Argument::type('string'))->shouldBeCalled();
     $progressBar->setOverwrite(false)->shouldBeCalled();
     $progressBar->finish()->shouldBeCalled();
     $output->writeln('')->shouldBeCalled();
     $this->finishProgress($event);
 }
开发者ID:Big-Shark,项目名称:grumphp,代码行数:11,代码来源:ProgressSubscriberSpec.php

示例5: restore

 /**
  * {@inheritdoc}
  *
  * @throws FileExistsException
  * @throws \InvalidArgumentException
  * @throws FileNotFoundException
  * @throws LogicException
  */
 public function restore(Filesystem $source, Filesystem $destination, ReadonlyDatabase $database, array $parameter)
 {
     // TODO make it smoother
     $files = $source->listFiles('', true);
     $progressBar = new ProgressBar($this->output, count($files));
     $progressBar->setOverwrite(true);
     $progressBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%');
     $progressBar->start();
     foreach ($files as $file) {
         $path = $file['path'];
         $fullPath = $parameter['directory'] . '/' . $file['path'];
         if ($destination->has($fullPath)) {
             if ($destination->hash($fullPath) === $source->hash($path)) {
                 $progressBar->advance();
                 continue;
             }
             $destination->delete($fullPath);
         }
         $destination->writeStream($fullPath, $source->readStream($path));
         $progressBar->advance();
     }
     $progressBar->finish();
 }
开发者ID:nanbando,项目名称:core,代码行数:31,代码来源:DirectoryPlugin.php

示例6: dumpData

 /**
  * @param            $table
  * @param Table      $tableConfig
  * @param Connection $db
  *
  * @throws \Doctrine\DBAL\DBALException
  */
 public function dumpData($table, Table $tableConfig, Connection $db)
 {
     $this->keepalive($db);
     $cols = $this->cols($table, $db);
     $s = "SELECT ";
     $first = true;
     foreach (array_keys($cols) as $name) {
         $isBlobColumn = $this->isBlob($name, $cols);
         if (!$first) {
             $s .= ', ';
         }
         $s .= $tableConfig->getSelectExpression($name, $isBlobColumn);
         $s .= " AS `{$name}`";
         $first = false;
     }
     $s .= " FROM `{$table}`";
     $s .= $tableConfig->getCondition();
     $this->output->writeln("-- BEGIN DATA {$table}", OutputInterface::OUTPUT_RAW);
     $bufferSize = 0;
     $max = 100 * 1024 * 1024;
     // 100 MB
     $numRows = $db->fetchColumn("SELECT COUNT(*) FROM {$table}");
     if ($numRows == 0) {
         // Fail fast: No data to dump.
         return;
     }
     $progress = new ProgressBar($this->output, $numRows);
     $progress->setFormat("Dumping data <fg=cyan>{$table}</>: <fg=yellow>%percent:3s%%</> %remaining%/%estimated%");
     $progress->setOverwrite(true);
     $progress->setRedrawFrequency(max($numRows / 100, 1));
     $progress->start();
     /** @var PDOConnection $wrappedConnection */
     $wrappedConnection = $db->getWrappedConnection();
     $wrappedConnection->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
     foreach ($db->query($s) as $row) {
         $b = $this->rowLengthEstimate($row);
         // Start a new statement to ensure that the line does not get too long.
         if ($bufferSize && $bufferSize + $b > $max) {
             $this->output->writeln(";", OutputInterface::OUTPUT_RAW);
             $bufferSize = 0;
         }
         if ($bufferSize == 0) {
             $this->output->write($this->insertValuesStatement($table, $cols), false, OutputInterface::OUTPUT_RAW);
         } else {
             $this->output->write(",", false, OutputInterface::OUTPUT_RAW);
         }
         $firstCol = true;
         $this->output->write("\n(", false, OutputInterface::OUTPUT_RAW);
         foreach ($row as $name => $value) {
             $isBlobColumn = $this->isBlob($name, $cols);
             if (!$firstCol) {
                 $this->output->write(", ", false, OutputInterface::OUTPUT_RAW);
             }
             $this->output->write($tableConfig->getStringForInsertStatement($name, $value, $isBlobColumn, $db), false, OutputInterface::OUTPUT_RAW);
             $firstCol = false;
         }
         $this->output->write(")", false, OutputInterface::OUTPUT_RAW);
         $bufferSize += $b;
         $progress->advance();
     }
     $progress->setFormat("Dumping data <fg=green>{$table}</>: <fg=green>%percent:3s%%</> Took: %elapsed%");
     $progress->finish();
     if ($this->output instanceof \Symfony\Component\Console\Output\ConsoleOutput) {
         $this->output->getErrorOutput()->write("\n");
         // write a newline after the progressbar.
     }
     $wrappedConnection->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
     if ($bufferSize) {
         $this->output->writeln(";", OutputInterface::OUTPUT_RAW);
     }
     $this->output->writeln('', OutputInterface::OUTPUT_RAW);
 }
开发者ID:webfactory,项目名称:slimdump,代码行数:79,代码来源:Dumper.php

示例7: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $bundlezip = $input->getOption('zip-file');
     if (!$bundlezip) {
         $helper = $this->getHelper('question');
         $question = new Question('<info>Please enter the name of the zip file:</info> <comment>[webflow]</comment> ', 'webflow');
         $bundlezip = $helper->ask($input, $output, $question);
     }
     $withZip = $bundlezip . ".zip";
     // Theme Name
     $theme = $input->getOption('theme-name');
     if (!$theme) {
         $helper = $this->getHelper('question');
         $question = new Question('<info>Please enter theme name:</info> <comment>[webflow]</comment> ', 'webflow');
         $theme = $helper->ask($input, $output, $question);
     }
     // Theme Description
     // $themeDesc = $input->getOption('theme-description');
     // if(!$themeDesc){
     //   $helper = $this->getHelper('question');
     //   $question = new Question('<info>Please enter theme description:</info> <comment>[These is a webflow theme]</comment> ', 'These is a webflow theme');
     //   $themeDesc = $helper->ask($input, $output, $question);
     // }
     $themeDesc = 'These is a webflow theme';
     $path = getcwd() . '/temp';
     $zip = new ZipArchive();
     if ($zip->open($withZip) === TRUE) {
         $zip->extractTo($path);
         $zip->close();
         $output->writeln('<info>Starting Theme creation process</info>');
     } else {
         $output->writeln('<comment>Failed to open the archive!</comment>');
         return false;
     }
     $directory = "{$path}/{$bundlezip}/";
     $htmlfiles = glob($directory . "*.html");
     $themeMachine = strtolower(str_replace(" ", "_", $theme));
     $Root = getcwd() . '/themes';
     $themeDir = "{$Root}/{$theme}";
     $create = new ClutchCli();
     $output = new ConsoleOutput();
     $output->setFormatter(new OutputFormatter(true));
     $rows = 8;
     $progressBar = new ProgressBar($output, $rows);
     $progressBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%');
     $progressBar->setBarCharacter('<fg=magenta>=</>');
     $progressBar->setProgressCharacter("🏃");
     $progressBar->setOverwrite(true);
     for ($i = 0; $i < $rows; $i++) {
         $create->Components($themeDir, $theme, $htmlfiles, 'data-component', 'components');
         $create->Components($themeDir, $theme, $htmlfiles, 'data-node', 'nodes');
         $create->Components($themeDir, $theme, $htmlfiles, 'data-menu', 'menus');
         $progressBar->advance(2);
         $create->Directory($path, $Root, $themeDir, $theme, $bundlezip);
         $progressBar->advance();
         $vars = array('{{themeName}}' => $theme, '{{themeMachine}}' => $themeMachine, '{{themeDescription}}' => $themeDesc);
         $progressBar->advance();
         $create->ThemeTemplates($themeDir, $theme, $vars);
         $progressBar->advance();
         $create->deleteDirectory($path);
         $progressBar->advance();
         \Drupal::service('theme_handler')->rebuildThemeData();
         $progressBar->advance();
         \Drupal::service('theme_handler')->reset();
         \Drupal::service('theme_handler')->refreshInfo();
         \Drupal::service('theme_handler')->listInfo();
         // $this->getChain()->addCommand('cache:rebuild', ['cache' => 'all']);
         // $this->getChain()->addCommand('clutch:sync', ['theme' => $theme]);
         $progressBar->advance();
         $output->writeln('<comment>' . "\r\n" . 'Your theme ' . $theme . ' is now created.</comment>');
         return true;
     }
     $progressBar->finish();
 }
开发者ID:poetic,项目名称:clutch,代码行数:78,代码来源:CreateCommand.php


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