| 1 | <?php |
||
| 9 | class InteractiveProcessManager |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var InteractiveProcess |
||
| 13 | */ |
||
| 14 | private $process; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var UserInteraction |
||
| 18 | */ |
||
| 19 | private $userInteraction; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param UserInteraction $userInteraction |
||
| 23 | */ |
||
| 24 | public function __construct(UserInteraction $userInteraction) |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Attach a process. |
||
| 31 | * |
||
| 32 | * @param InteractiveProcess $process |
||
| 33 | */ |
||
| 34 | public function setProcess(InteractiveProcess $process) |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Disable the process output. |
||
| 41 | */ |
||
| 42 | public function disableOutput() |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Enable the process output. |
||
| 49 | * |
||
| 50 | * @param bool $retroActive |
||
| 51 | */ |
||
| 52 | public function enableOutput($retroActive = false) |
||
| 53 | { |
||
| 54 | $pipe = new UserInteractionPipe($this->userInteraction); |
||
| 55 | if ($retroActive) { |
||
| 56 | $pipe->rewind($this->process); |
||
| 57 | } |
||
| 58 | |||
| 59 | $this->process->updatePipe($pipe); |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Run the given process. |
||
| 64 | */ |
||
| 65 | public function run() |
||
| 69 | } |
||
| 70 |