You are here

public function DebugFormatterHelper::progress in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/console/Helper/DebugFormatterHelper.php \Symfony\Component\Console\Helper\DebugFormatterHelper::progress()

Adds progress to a formatting session.

Parameters

string $id The id of the formatting session:

string $buffer The message to display:

bool $error Whether to consider the buffer as error:

string $prefix The prefix for output:

string $errorPrefix The prefix for error output:

Return value

string

File

vendor/symfony/console/Helper/DebugFormatterHelper.php, line 54

Class

DebugFormatterHelper
Helps outputting debug information when running an external program from a command.

Namespace

Symfony\Component\Console\Helper

Code

public function progress($id, $buffer, $error = false, $prefix = 'OUT', $errorPrefix = 'ERR') {
  $message = '';
  if ($error) {
    if (isset($this->started[$id]['out'])) {
      $message .= "\n";
      unset($this->started[$id]['out']);
    }
    if (!isset($this->started[$id]['err'])) {
      $message .= sprintf('%s<bg=red;fg=white> %s </> ', $this
        ->getBorder($id), $errorPrefix);
      $this->started[$id]['err'] = true;
    }
    $message .= str_replace("\n", sprintf("\n%s<bg=red;fg=white> %s </> ", $this
      ->getBorder($id), $errorPrefix), $buffer);
  }
  else {
    if (isset($this->started[$id]['err'])) {
      $message .= "\n";
      unset($this->started[$id]['err']);
    }
    if (!isset($this->started[$id]['out'])) {
      $message .= sprintf('%s<bg=green;fg=white> %s </> ', $this
        ->getBorder($id), $prefix);
      $this->started[$id]['out'] = true;
    }
    $message .= str_replace("\n", sprintf("\n%s<bg=green;fg=white> %s </> ", $this
      ->getBorder($id), $prefix), $buffer);
  }
  return $message;
}