Skip to content

Commit cae48de

Browse files
committed
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 command a5f36a8 [Console] Add threshold for ProcessHelper verbosity
2 parents cc4daa7 + 9a374f1 commit cae48de

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

Helper/ProcessHelper.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@ class ProcessHelper extends Helper
2626
/**
2727
* Runs an external process.
2828
*
29-
* @param OutputInterface $output An OutputInterface instance
30-
* @param string|array|Process $cmd An instance of Process or an array of arguments to escape and run or a command to run
31-
* @param string|null $error An error message that must be displayed if something went wrong
32-
* @param callable|null $callback A PHP callback to run whenever there is some
33-
* output available on STDOUT or STDERR
29+
* @param OutputInterface $output An OutputInterface instance
30+
* @param string|array|Process $cmd An instance of Process or an array of arguments to escape and run or a command to run
31+
* @param string|null $error An error message that must be displayed if something went wrong
32+
* @param callable|null $callback A PHP callback to run whenever there is some
33+
* output available on STDOUT or STDERR
34+
* @param int $verbosity The threshold for verbosity
3435
*
3536
* @return Process The process that ran
3637
*/
37-
public function run(OutputInterface $output, $cmd, $error = null, $callback = null)
38+
public function run(OutputInterface $output, $cmd, $error = null, $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE)
3839
{
3940
$formatter = $this->getHelperSet()->get('debug_formatter');
4041

@@ -46,7 +47,7 @@ public function run(OutputInterface $output, $cmd, $error = null, $callback = nu
4647
$process = new Process($cmd);
4748
}
4849

49-
if ($output->isVeryVerbose()) {
50+
if ($verbosity <= $output->getVerbosity()) {
5051
$output->write($formatter->start(spl_object_hash($process), $process->getCommandLine()));
5152
}
5253

@@ -56,7 +57,7 @@ public function run(OutputInterface $output, $cmd, $error = null, $callback = nu
5657

5758
$process->run($callback);
5859

59-
if ($output->isVeryVerbose()) {
60+
if ($verbosity <= $output->getVerbosity()) {
6061
$message = $process->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process->getExitCode());
6162
$output->write($formatter->stop(spl_object_hash($process), $message, $process->isSuccessful()));
6263
}

0 commit comments

Comments
 (0)