1 | <?php |
||
8 | class ShellExecutor implements ExecutorInterface |
||
9 | { |
||
10 | /** |
||
11 | * @param string $command |
||
12 | * @param OutputInterface|null $output |
||
13 | * |
||
14 | * @return int |
||
15 | */ |
||
16 | 1 | public function execute($command, OutputInterface $output = null) |
|
17 | { |
||
18 | 1 | $process = new Process($command); |
|
19 | 1 | $process->setTimeout(120); |
|
20 | |||
21 | 1 | $process->run(function ($type, $buffer) use ($output) { |
|
22 | 1 | $output->writeln($buffer); |
|
23 | 1 | }); |
|
24 | |||
25 | 1 | if (!$process->isSuccessful()) { |
|
26 | throw new \RuntimeException($process->getErrorOutput()); |
||
27 | } |
||
28 | |||
29 | 1 | return $process->getExitCode(); |
|
30 | } |
||
31 | |||
32 | /** |
||
33 | * @return string |
||
34 | */ |
||
35 | 4 | public function getName() |
|
39 | } |
||
40 |