1 | <?php |
||
27 | class CommandExecutor |
||
28 | { |
||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $host; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $path; |
||
38 | |||
39 | /** |
||
40 | * @var string |
||
41 | */ |
||
42 | protected $cwd; |
||
43 | |||
44 | /** |
||
45 | * @var string |
||
46 | */ |
||
47 | protected $console; |
||
48 | |||
49 | /** |
||
50 | * @var PhpFinder |
||
51 | */ |
||
52 | protected $finder; |
||
53 | |||
54 | /** |
||
55 | * @var int |
||
56 | */ |
||
57 | const TIMEOUT = 2; |
||
58 | |||
59 | /** |
||
60 | * @param PhpFinder $finder |
||
61 | * @param RouterInterface $router |
||
62 | * @param RequestStack $request_stack |
||
63 | * @param string $root_dir |
||
64 | */ |
||
65 | 5 | public function __construct(PhpFinder $finder, RouterInterface $router, RequestStack $request_stack, $root_dir) |
|
75 | |||
76 | /** |
||
77 | * @deprecated see self::send() |
||
78 | * |
||
79 | * @throws \InvalidArgumentException |
||
80 | * |
||
81 | * @param string $command |
||
82 | */ |
||
83 | public function exec($command) |
||
90 | |||
91 | /** |
||
92 | * Execute command |
||
93 | * |
||
94 | * If timeout <= 0 and callback is null then command will be executed in background |
||
95 | * |
||
96 | * @param string $command |
||
97 | * @param int $timeout |
||
98 | * @param callable|null $callback |
||
99 | */ |
||
100 | public function execute($command, $timeout = 300, $callback = null) |
||
108 | |||
109 | /** |
||
110 | * @param string $command |
||
111 | * @param int $timeout |
||
112 | * @param callable|null $callback |
||
113 | */ |
||
114 | public function console($command, $timeout = 300, $callback = null) |
||
118 | |||
119 | /** |
||
120 | * @throws \RuntimeException |
||
121 | * |
||
122 | * @param string $command |
||
123 | * @param int $timeout |
||
124 | * @param callable|null $callback |
||
125 | */ |
||
126 | protected function executeCommand($command, $timeout = 300, $callback = null) |
||
134 | |||
135 | /** |
||
136 | * @param string $command |
||
137 | */ |
||
138 | protected function executeCommandInBackground($command) |
||
152 | |||
153 | /** |
||
154 | * Send the command to perform in a new thread |
||
155 | * |
||
156 | * @param string $command |
||
157 | * @param string $host |
||
158 | */ |
||
159 | 1 | public function send($command, $host = '') |
|
177 | |||
178 | /** |
||
179 | * @param string $command |
||
180 | * |
||
181 | * @return string |
||
182 | */ |
||
183 | 3 | public function prepare($command) |
|
200 | } |
||
201 |