Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ProgressBar.php

function ProgressBar::overwrite

Overwrites a previous message to the output.

2 calls to ProgressBar::overwrite()
ProgressBar::clear in vendor/symfony/console/Helper/ProgressBar.php
Removes the progress bar from the current line.
ProgressBar::display in vendor/symfony/console/Helper/ProgressBar.php
Outputs the current progress string.

File

vendor/symfony/console/Helper/ProgressBar.php, line 503

Class

ProgressBar
The ProgressBar provides helpers to display progress output.

Namespace

Symfony\Component\Console\Helper

Code

private function overwrite(string $message) : void {
    if ($this->previousMessage === $message) {
        return;
    }
    $originalMessage = $message;
    if ($this->overwrite) {
        if (null !== $this->previousMessage) {
            if ($this->output instanceof ConsoleSectionOutput) {
                $messageLines = explode("\n", $this->previousMessage);
                $lineCount = \count($messageLines);
                foreach ($messageLines as $messageLine) {
                    $messageLineLength = Helper::width(Helper::removeDecoration($this->output
                        ->getFormatter(), $messageLine));
                    if ($messageLineLength > $this->terminal
                        ->getWidth()) {
                        $lineCount += floor($messageLineLength / $this->terminal
                            ->getWidth());
                    }
                }
                $this->output
                    ->clear($lineCount);
            }
            else {
                $lineCount = substr_count($this->previousMessage, "\n");
                for ($i = 0; $i < $lineCount; ++$i) {
                    $this->cursor
                        ->moveToColumn(1);
                    $this->cursor
                        ->clearLine();
                    $this->cursor
                        ->moveUp();
                }
                $this->cursor
                    ->moveToColumn(1);
                $this->cursor
                    ->clearLine();
            }
        }
    }
    elseif ($this->step > 0) {
        $message = \PHP_EOL . $message;
    }
    $this->previousMessage = $originalMessage;
    $this->lastWriteTime = microtime(true);
    $this->output
        ->write($message);
    ++$this->writeCount;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal