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


PHP SymfonyStyle::createProgressBar方法代码示例

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


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

示例1: create_progress_bar

 /**
  * Create a styled progress bar
  *
  * @param  integer $max Max value for the progress bar
  * @return \Symfony\Component\Console\Helper\ProgressBar
  */
 protected function create_progress_bar($max)
 {
     $progress = $this->io->createProgressBar($max);
     if ($this->output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE) {
         $progress->setFormat('<info>[%percent:3s%%]</info> %message%');
         $progress->setOverwrite(false);
     } else {
         if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) {
             $progress->setFormat('<info>[%current:s%/%max:s%]</info><comment>[%elapsed%/%estimated%][%memory%]</comment> %message%');
             $progress->setOverwrite(false);
         } else {
             $this->io->newLine(2);
             $progress->setFormat("    %current:s%/%max:s% %bar%  %percent:3s%%\n" . "        %message% %elapsed:6s%/%estimated:-6s% %memory:6s%\n");
             $progress->setBarWidth(60);
         }
     }
     if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
         $progress->setEmptyBarCharacter('░');
         // light shade character \u2591
         $progress->setProgressCharacter('');
         $progress->setBarCharacter('▓');
         // dark shade character \u2593
     }
     return $progress;
 }
开发者ID:MrAdder,项目名称:phpbb,代码行数:31,代码来源:reparse.php

示例2: reparse

 /**
  * Reparse all text handled by given reparser within given range
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  * @param string $name Reparser name
  * @return null
  */
 protected function reparse(InputInterface $input, OutputInterface $output, $name)
 {
     $reparser = $this->reparsers[$name];
     if ($input->getOption('dry-run')) {
         $reparser->disable_save();
     } else {
         $reparser->enable_save();
     }
     // Start at range-max if specified or at the highest ID otherwise
     $max = is_null($input->getOption('range-max')) ? $reparser->get_max_id() : $input->getOption('range-max');
     $min = $input->getOption('range-min');
     $size = $input->getOption('range-size');
     if ($max === 0) {
         return;
     }
     $this->io->section($this->user->lang('CLI_REPARSER_REPARSE_REPARSING', str_replace('text_reparser.', '', $name), $min, $max));
     $progress = $this->io->createProgressBar($max);
     if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE) {
         $progress->setFormat('<info>[%percent:3s%%]</info> %message%');
         $progress->setOverwrite(false);
     } else {
         if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) {
             $progress->setFormat('<info>[%current:s%/%max:s%]</info><comment>[%elapsed%/%estimated%][%memory%]</comment> %message%');
             $progress->setOverwrite(false);
         } else {
             $this->io->newLine(2);
             $progress->setFormat("    %current:s%/%max:s% %bar%  %percent:3s%%\n" . "        %message% %elapsed:6s%/%estimated:-6s% %memory:6s%\n");
             $progress->setBarWidth(60);
         }
     }
     $progress->setMessage($this->user->lang('CLI_REPARSER_REPARSE_REPARSING_START', str_replace('text_reparser.', '', $name)));
     if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
         $progress->setEmptyBarCharacter('░');
         // light shade character \u2591
         $progress->setProgressCharacter('');
         $progress->setBarCharacter('▓');
         // dark shade character \u2593
     }
     $progress->start();
     // Start from $max and decrement $current by $size until we reach $min
     $current = $max;
     while ($current >= $min) {
         $start = max($min, $current + 1 - $size);
         $end = max($min, $current);
         $progress->setMessage($this->user->lang('CLI_REPARSER_REPARSE_REPARSING', str_replace('text_reparser.', '', $name), $start, $end));
         $reparser->reparse_range($start, $end);
         $current = $start - 1;
         $progress->setProgress($max + 1 - $start);
     }
     $progress->finish();
     $this->io->newLine(2);
 }
开发者ID:Alexey3112,项目名称:phpbb,代码行数:60,代码来源:reparse.php

示例3: execute

 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->dispatcher = $this->getContainer()->get('event_dispatcher');
     $this->output = new SymfonyStyle($input, $output);
     $this->dispatcher->dispatch(BotEvent::START, BotEvent::create('START'));
     $this->output->title((new \DateTime())->format('Y-m-d H:i:s') . 'Starting ' . $this->getContainer()->getParameter('name'));
     $this->updateModules();
     $this->fillIgnoredRepository();
     /** @var Discord $discord */
     $discord = $this->getContainer()->get('discord');
     $this->dispatcher->dispatch(BotEvent::PREPARE, BotEvent::create('PREPARE'));
     $discord->on('error', [$this, 'logError']);
     $servers = 0;
     $progress = null;
     $this->output->note('Loading up servers. Please wait.');
     $progress = $this->output->createProgressBar($this->getTotalServers());
     $discord->on('available', function () use(&$servers, $progress) {
         $servers++;
         $this->updateServerFile($servers);
         if ($progress !== null) {
             $progress->advance();
         }
     });
     $discord->on('ready', function () use($discord, &$servers, $progress) {
         $this->dispatcher->dispatch(BotEvent::READY_START, BotEvent::create('READY_START'));
         $this->updateServerFile($servers);
         if ($progress !== null) {
             $progress->finish();
             $this->output->newLine(2);
         }
         $this->getContainer()->get('listener.discord')->listen();
         $this->output->success('Bot is ready!');
         $this->createServerManagers();
         $status = $this->getContainer()->getParameter('status');
         $this->output->note('Setting status to: ' . $status['name']);
         $discord->updatePresence($discord->factory(Game::class, $status), false);
         $this->dispatcher->dispatch(BotEvent::READY_FINISH, BotEvent::create('READY_FINISH'));
     });
     try {
         $discord->run();
     } catch (ContextErrorException $e) {
     }
 }
开发者ID:lfgamers,项目名称:discord-base-bot,代码行数:49,代码来源:RunCommand.php

示例4: createProgressBar

 /**
  * @phpcsSuppress SlevomatCodingStandard.Typehints.TypeHintDeclaration.missingParameterTypeHint
  * @param int $max
  */
 public function createProgressBar($max = 0) : ProgressBar
 {
     $this->progressBar = parent::createProgressBar($max);
     return $this->progressBar;
 }
开发者ID:phpstan,项目名称:phpstan,代码行数:9,代码来源:ErrorsConsoleStyle.php

示例5: createProgressBar

 public function createProgressBar($max = 0)
 {
     $progress = $this->interactive->createProgressBar($max);
     $progress->setBarWidth(Cli::getConsoleWidth() - 12 - strlen($max) * 2);
     return $progress;
 }
开发者ID:phwoolcon,项目名称:phwoolcon,代码行数:6,代码来源:Command.php

示例6: execute

    /**
     * Executes the command thumbnail:generate.
     *
     * Generate a thumbnail for all attachments which need one and don't have it yet.
     *
     * @param InputInterface $input The input stream used to get the argument and verboe option.
     * @param OutputInterface $output The output stream, used for printing verbose-mode and error information.
     *
     * @return int 0.
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input, $output);
        $io->section($this->user->lang('CLI_THUMBNAIL_GENERATING'));
        $sql = 'SELECT COUNT(*) AS nb_missing_thumbnails
			FROM ' . ATTACHMENTS_TABLE . '
			WHERE thumbnail = 0';
        $result = $this->db->sql_query($sql);
        $nb_missing_thumbnails = (int) $this->db->sql_fetchfield('nb_missing_thumbnails');
        $this->db->sql_freeresult($result);
        if ($nb_missing_thumbnails === 0) {
            $io->warning($this->user->lang('CLI_THUMBNAIL_NOTHING_TO_GENERATE'));
            return 0;
        }
        $extensions = $this->cache->obtain_attach_extensions(true);
        $sql = 'SELECT attach_id, physical_filename, extension, real_filename, mimetype
			FROM ' . ATTACHMENTS_TABLE . '
			WHERE thumbnail = 0';
        $result = $this->db->sql_query($sql);
        if (!function_exists('create_thumbnail')) {
            require $this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext;
        }
        $progress = $io->createProgressBar($nb_missing_thumbnails);
        if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE) {
            $progress->setFormat('<info>[%percent:3s%%]</info> %message%');
            $progress->setOverwrite(false);
        } else {
            if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) {
                $progress->setFormat('<info>[%current:s%/%max:s%]</info><comment>[%elapsed%/%estimated%][%memory%]</comment> %message%');
                $progress->setOverwrite(false);
            } else {
                $io->newLine(2);
                $progress->setFormat("    %current:s%/%max:s% %bar%  %percent:3s%%\n" . "                         %elapsed:6s%/%estimated:-6s% %memory:6s%\n");
                $progress->setBarWidth(60);
            }
        }
        if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
            $progress->setEmptyBarCharacter('░');
            // light shade character \u2591
            $progress->setProgressCharacter('');
            $progress->setBarCharacter('▓');
            // dark shade character \u2593
        }
        $progress->setMessage($this->user->lang('CLI_THUMBNAIL_GENERATING'));
        $progress->start();
        $thumbnail_created = array();
        while ($row = $this->db->sql_fetchrow($result)) {
            if (isset($extensions[$row['extension']]['display_cat']) && $extensions[$row['extension']]['display_cat'] == ATTACHMENT_CATEGORY_IMAGE) {
                $source = $this->phpbb_root_path . 'files/' . $row['physical_filename'];
                $destination = $this->phpbb_root_path . 'files/thumb_' . $row['physical_filename'];
                if (create_thumbnail($source, $destination, $row['mimetype'])) {
                    $thumbnail_created[] = (int) $row['attach_id'];
                    if (count($thumbnail_created) === 250) {
                        $this->commit_changes($thumbnail_created);
                        $thumbnail_created = array();
                    }
                    $progress->setMessage($this->user->lang('CLI_THUMBNAIL_GENERATED', $row['real_filename'], $row['physical_filename']));
                } else {
                    $progress->setMessage('<info>' . $this->user->lang('CLI_THUMBNAIL_SKIPPED', $row['real_filename'], $row['physical_filename']) . '</info>');
                }
            }
            $progress->advance();
        }
        $this->db->sql_freeresult($result);
        if (!empty($thumbnail_created)) {
            $this->commit_changes($thumbnail_created);
        }
        $progress->finish();
        $io->newLine(2);
        $io->success($this->user->lang('CLI_THUMBNAIL_GENERATING_DONE'));
        return 0;
    }
开发者ID:MrAdder,项目名称:phpbb,代码行数:82,代码来源:generate.php

示例7: execute

    /**
     * Executes the command thumbnail:delete.
     *
     * Deletes all existing thumbnails and updates the database accordingly.
     *
     * @param InputInterface $input The input stream used to get the argument and verbose option.
     * @param OutputInterface $output The output stream, used for printing verbose-mode and error information.
     *
     * @return int 0 if all is ok, 1 if a thumbnail couldn't be deleted.
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input, $output);
        $io->section($this->user->lang('CLI_THUMBNAIL_DELETING'));
        $sql = 'SELECT COUNT(*) AS nb_missing_thumbnails
			FROM ' . ATTACHMENTS_TABLE . '
			WHERE thumbnail = 1';
        $result = $this->db->sql_query($sql);
        $nb_missing_thumbnails = (int) $this->db->sql_fetchfield('nb_missing_thumbnails');
        $this->db->sql_freeresult($result);
        if ($nb_missing_thumbnails === 0) {
            $io->warning($this->user->lang('CLI_THUMBNAIL_NOTHING_TO_DELETE'));
            return 0;
        }
        $sql = 'SELECT attach_id, physical_filename, extension, real_filename, mimetype
			FROM ' . ATTACHMENTS_TABLE . '
			WHERE thumbnail = 1';
        $result = $this->db->sql_query($sql);
        $progress = $io->createProgressBar($nb_missing_thumbnails);
        if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE) {
            $progress->setFormat('<info>[%percent:3s%%]</info> %message%');
            $progress->setOverwrite(false);
        } else {
            if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) {
                $progress->setFormat('<info>[%current:s%/%max:s%]</info><comment>[%elapsed%/%estimated%][%memory%]</comment> %message%');
                $progress->setOverwrite(false);
            } else {
                $io->newLine(2);
                $progress->setFormat("    %current:s%/%max:s% %bar%  %percent:3s%%\n" . "                         %elapsed:6s%/%estimated:-6s% %memory:6s%\n");
                $progress->setBarWidth(60);
            }
        }
        if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
            $progress->setEmptyBarCharacter('░');
            // light shade character \u2591
            $progress->setProgressCharacter('');
            $progress->setBarCharacter('▓');
            // dark shade character \u2593
        }
        $progress->setMessage($this->user->lang('CLI_THUMBNAIL_DELETING'));
        $progress->start();
        $thumbnail_deleted = array();
        $return = 0;
        while ($row = $this->db->sql_fetchrow($result)) {
            $thumbnail_path = $this->phpbb_root_path . 'files/thumb_' . $row['physical_filename'];
            if (@unlink($thumbnail_path)) {
                $thumbnail_deleted[] = $row['attach_id'];
                if (sizeof($thumbnail_deleted) === 250) {
                    $this->commit_changes($thumbnail_deleted);
                    $thumbnail_deleted = array();
                }
                $progress->setMessage($this->user->lang('CLI_THUMBNAIL_DELETED', $row['real_filename'], $row['physical_filename']));
            } else {
                $return = 1;
                $progress->setMessage('<error>' . $this->user->lang('CLI_THUMBNAIL_SKIPPED', $row['real_filename'], $row['physical_filename']) . '</error>');
            }
            $progress->advance();
        }
        $this->db->sql_freeresult($result);
        if (!empty($thumbnail_deleted)) {
            $this->commit_changes($thumbnail_deleted);
        }
        $progress->finish();
        $io->newLine(2);
        $io->success($this->user->lang('CLI_THUMBNAIL_DELETING_DONE'));
        return $return;
    }
开发者ID:MrAdder,项目名称:phpbb,代码行数:77,代码来源:delete.php


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