12 namespace Symfony\Component\Console\Helper;
15 use Symfony\Component\Process\Exception\ProcessFailedException;
16 use Symfony\Component\Process\Process;
17 use Symfony\Component\Process\ProcessBuilder;
40 $formatter = $this->
getHelperSet()->get(
'debug_formatter');
43 $process = ProcessBuilder::create($cmd)->getProcess();
44 }
elseif ($cmd instanceof Process) {
47 $process =
new Process($cmd);
50 if ($verbosity <= $output->getVerbosity()) {
51 $output->
write($formatter->start(spl_object_hash($process), $this->
escapeString($process->getCommandLine())));
54 if ($output->isDebug()) {
55 $callback = $this->
wrapCallback($output, $process, $callback);
58 $process->run($callback);
60 if ($verbosity <= $output->getVerbosity()) {
61 $message = $process->isSuccessful() ?
'Command ran successfully' : sprintf(
'%s Command did not run successfully', $process->getExitCode());
62 $output->
write($formatter->stop(spl_object_hash($process), $message, $process->isSuccessful()));
65 if (!$process->isSuccessful() && null !== $error) {
92 $process = $this->
run($output, $cmd, $error, $callback);
94 if (!$process->isSuccessful()) {
95 throw new ProcessFailedException($process);
112 $formatter = $this->
getHelperSet()->get(
'debug_formatter');
116 return function ($type, $buffer) use ($output, $process, $callback, $formatter, $that) {
117 $output->
write($formatter->progress(spl_object_hash($process), $that->escapeString($buffer), Process::ERR === $type));
119 if (null !== $callback) {
120 call_user_func($callback, $type, $buffer);
132 return str_replace(
'<',
'\\<', $str);