protected function Process::buildCallback

Builds up the callback used by wait().

The callbacks adds all occurred output to the specific buffer and calls the user callback (if present) with the received output.

Parameters

mixed $callback The user defined PHP callback:

Return value

mixed A PHP callable

2 calls to Process::buildCallback()
Process::start in drupal/core/vendor/symfony/process/Symfony/Component/Process/Process.php
Starts the process and returns after sending the STDIN.
Process::wait in drupal/core/vendor/symfony/process/Symfony/Component/Process/Process.php
Waits for the process to terminate.

File

drupal/core/vendor/symfony/process/Symfony/Component/Process/Process.php, line 691

Class

Process
Process is a thin wrapper around proc_* functions to ease start independent PHP processes.

Namespace

Symfony\Component\Process

Code

protected function buildCallback($callback) {
  $that = $this;
  $out = self::OUT;
  $err = self::ERR;
  $callback = function ($type, $data) use ($that, $callback, $out, $err) {
    if ($out == $type) {
      $that
        ->addOutput($data);
    }
    else {
      $that
        ->addErrorOutput($data);
    }
    if (null !== $callback) {
      call_user_func($callback, $type, $data);
    }
  };
  return $callback;
}