feature #11135 [FrameworkBundle] Use ProcessHelper for server:run command (romainneutron)
This PR was merged into the 2.6-dev branch. Discussion ---------- [FrameworkBundle] Use ProcessHelper for server:run command | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT Let's use our new process helper :) Commits -------6ca1c90
[FrameworkBundle] Use ProcessHelper for server:run commanda5f36a8
[Console] Add threshold for ProcessHelper verbosity
This commit is contained in:
commit
adb78608c9
@ -95,16 +95,13 @@ EOF
|
||||
$builder->setTimeout(null);
|
||||
$process = $builder->getProcess();
|
||||
|
||||
if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
|
||||
$callback = function ($type, $buffer) use ($output) {
|
||||
$output->write($buffer);
|
||||
};
|
||||
} else {
|
||||
$callback = null;
|
||||
if (OutputInterface::VERBOSITY_VERBOSE > $output->getVerbosity()) {
|
||||
$process->disableOutput();
|
||||
}
|
||||
|
||||
$process->run($callback);
|
||||
$this
|
||||
->getHelper('process')
|
||||
->run($output, $process, null, null, OutputInterface::VERBOSITY_VERBOSE);
|
||||
}
|
||||
|
||||
private function createPhpProcessBuilder(InputInterface $input, OutputInterface $output, $env)
|
||||
|
@ -31,10 +31,11 @@ class ProcessHelper extends Helper
|
||||
* @param string|null $error An error message that must be displayed if something went wrong
|
||||
* @param callable|null $callback A PHP callback to run whenever there is some
|
||||
* output available on STDOUT or STDERR
|
||||
* @param int $verbosity The threshold for verbosity
|
||||
*
|
||||
* @return Process The process that ran
|
||||
*/
|
||||
public function run(OutputInterface $output, $cmd, $error = null, $callback = null)
|
||||
public function run(OutputInterface $output, $cmd, $error = null, $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE)
|
||||
{
|
||||
$formatter = $this->getHelperSet()->get('debug_formatter');
|
||||
|
||||
@ -46,7 +47,7 @@ class ProcessHelper extends Helper
|
||||
$process = new Process($cmd);
|
||||
}
|
||||
|
||||
if ($output->isVeryVerbose()) {
|
||||
if ($verbosity <= $output->getVerbosity()) {
|
||||
$output->write($formatter->start(spl_object_hash($process), $process->getCommandLine()));
|
||||
}
|
||||
|
||||
@ -56,7 +57,7 @@ class ProcessHelper extends Helper
|
||||
|
||||
$process->run($callback);
|
||||
|
||||
if ($output->isVeryVerbose()) {
|
||||
if ($verbosity <= $output->getVerbosity()) {
|
||||
$message = $process->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process->getExitCode());
|
||||
$output->write($formatter->stop(spl_object_hash($process), $message, $process->isSuccessful()));
|
||||
}
|
||||
|
Reference in New Issue
Block a user