[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/phpbb/console/command/ -> command.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  namespace phpbb\console\command;
  15  
  16  use Symfony\Component\Console\Helper\ProgressBar;
  17  use Symfony\Component\Console\Output\OutputInterface;
  18  use Symfony\Component\Console\Style\SymfonyStyle;
  19  
  20  abstract class command extends \Symfony\Component\Console\Command\Command
  21  {
  22      /** @var \phpbb\user */
  23      protected $user;
  24  
  25      /**
  26      * Constructor
  27      *
  28      * @param \phpbb\user $user User instance (mostly for translation)
  29      */
  30  	public function __construct(\phpbb\user $user)
  31      {
  32          $this->user = $user;
  33          parent::__construct();
  34      }
  35  
  36      /**
  37       * Create a styled progress bar
  38       *
  39       * @param int             $max     Max value for the progress bar
  40       * @param SymfonyStyle    $io      Symfony style output decorator
  41       * @param OutputInterface $output  The output stream, used to print messages
  42       * @param bool            $message Should we display message output under the progress bar?
  43       * @return ProgressBar
  44       */
  45  	public function create_progress_bar($max, SymfonyStyle $io, OutputInterface $output, $message = false)
  46      {
  47          $progress = $io->createProgressBar($max);
  48          if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE)
  49          {
  50              $progress->setFormat('<info>[%percent:3s%%]</info> %message%');
  51              $progress->setOverwrite(false);
  52          }
  53          else if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE)
  54          {
  55              $progress->setFormat('<info>[%current:s%/%max:s%]</info><comment>[%elapsed%/%estimated%][%memory%]</comment> %message%');
  56              $progress->setOverwrite(false);
  57          }
  58          else
  59          {
  60              $io->newLine(2);
  61              $progress->setFormat(
  62                  "    %current:s%/%max:s% %bar%  %percent:3s%%\n" .
  63                  "        " . ($message ? '%message%' : '                ') . " %elapsed:6s%/%estimated:-6s% %memory:6s%\n");
  64              $progress->setBarWidth(60);
  65          }
  66  
  67          if (!defined('PHP_WINDOWS_VERSION_BUILD'))
  68          {
  69              $progress->setEmptyBarCharacter('░'); // light shade character \u2591
  70              $progress->setProgressCharacter('');
  71              $progress->setBarCharacter('▓'); // dark shade character \u2593
  72          }
  73  
  74          return $progress;
  75      }
  76  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1