1 | <?php |
||
9 | class SuiteListener implements EventSubscriberInterface |
||
10 | { |
||
11 | /** @var array */ |
||
12 | private $commands; |
||
13 | /** @var string */ |
||
14 | private $winPrefix; |
||
15 | /** @var string */ |
||
16 | private $nixPrefix; |
||
17 | /** @var string */ |
||
18 | private $workingDirectory; |
||
19 | /** @var array|\Symfony\Component\Process\Process[] */ |
||
20 | private $processes = array(); |
||
21 | /** @var int */ |
||
22 | private $sleep = 0; |
||
23 | |||
24 | /** |
||
25 | * Construct listener |
||
26 | * |
||
27 | * @param array $commands commands in array format |
||
28 | * @param null $workingDirectory working directory for commands |
||
29 | * @param string $nixPrefix prefix for *nix-based OS, default "exec" |
||
30 | * @param string $winPrefix prefix for Windows OS |
||
31 | * @param int $sleep sleep after spawn (in milliseconds) |
||
32 | */ |
||
33 | public function __construct( |
||
46 | |||
47 | /** |
||
48 | * Returns an array of event names this subscriber wants to listen to. |
||
49 | * |
||
50 | * The array keys are event names and the value can be: |
||
51 | * |
||
52 | * * The method name to call (priority defaults to 0) |
||
53 | * * An array composed of the method name to call and the priority |
||
54 | * * An array of arrays composed of the method names to call and respective |
||
55 | * priorities, or 0 if unset |
||
56 | * |
||
57 | * For instance: |
||
58 | * |
||
59 | * * array('eventName' => 'methodName') |
||
60 | * * array('eventName' => array('methodName', $priority)) |
||
61 | * * array('eventName' => array(array('methodName1', $priority), array('methodName2')) |
||
62 | * |
||
63 | * @return array The event names to listen to |
||
64 | * |
||
65 | * @api |
||
66 | */ |
||
67 | public static function getSubscribedEvents() |
||
74 | |||
75 | /** |
||
76 | * @return array |
||
77 | */ |
||
78 | public function getCommands() |
||
82 | |||
83 | /** |
||
84 | * @return string |
||
85 | */ |
||
86 | public function getWinPrefix() |
||
90 | |||
91 | /** |
||
92 | * @return string |
||
93 | */ |
||
94 | public function getNixPrefix() |
||
98 | |||
99 | /** |
||
100 | * @return string|null |
||
101 | */ |
||
102 | public function getWorkingDirectory() |
||
106 | |||
107 | /** |
||
108 | * Spawns processes |
||
109 | */ |
||
110 | public function spawnProcesses() |
||
127 | |||
128 | /** |
||
129 | * Normalize working dir (set to '.' if empty) |
||
130 | * |
||
131 | * @return string |
||
132 | */ |
||
133 | private function getNormalizedWorkdir() |
||
141 | |||
142 | /** |
||
143 | * Get prefix based on current platform (Windows/*-nix) |
||
144 | * |
||
145 | * @return string |
||
146 | */ |
||
147 | private function getPlatformPrefix() |
||
155 | |||
156 | /** |
||
157 | * @param array $arguments |
||
158 | * @param string $execPrefix |
||
159 | * @param string $workingDirectory |
||
160 | * |
||
161 | * @return \Symfony\Component\Process\Process |
||
162 | */ |
||
163 | private function createProcess($arguments, $execPrefix, $workingDirectory) |
||
178 | |||
179 | /** |
||
180 | * Sleep if processes has been spawned and sleep option configured |
||
181 | */ |
||
182 | private function sleepIfSpawned() |
||
188 | |||
189 | /** |
||
190 | * Stops processes |
||
191 | */ |
||
192 | public function stopProcesses() |
||
200 | |||
201 | /** |
||
202 | * @return array|\Symfony\Component\Process\Process[] |
||
203 | */ |
||
204 | public function getProcesses() |
||
208 | |||
209 | /** |
||
210 | * @return int |
||
211 | */ |
||
212 | public function getSleep() |
||
216 | } |
||
217 |