You are here

public function ProcessHelper::wrapCallback in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/console/Helper/ProcessHelper.php \Symfony\Component\Console\Helper\ProcessHelper::wrapCallback()

Wraps a Process callback to add debugging output.

Parameters

OutputInterface $output An OutputInterface interface:

Process $process The Process:

callable|null $callback A PHP callable:

Return value

callable

1 call to ProcessHelper::wrapCallback()
ProcessHelper::run in vendor/symfony/console/Helper/ProcessHelper.php
Runs an external process.

File

vendor/symfony/console/Helper/ProcessHelper.php, line 115

Class

ProcessHelper
The ProcessHelper class provides helpers to run external processes.

Namespace

Symfony\Component\Console\Helper

Code

public function wrapCallback(OutputInterface $output, Process $process, $callback = null) {
  if ($output instanceof ConsoleOutputInterface) {
    $output = $output
      ->getErrorOutput();
  }
  $formatter = $this
    ->getHelperSet()
    ->get('debug_formatter');
  $that = $this;
  return function ($type, $buffer) use ($output, $process, $callback, $formatter, $that) {
    $output
      ->write($formatter
      ->progress(spl_object_hash($process), $that
      ->escapeString($buffer), Process::ERR === $type));
    if (null !== $callback) {
      call_user_func($callback, $type, $buffer);
    }
  };
}