1 | <?php |
||
20 | class ProvisionDispatcher |
||
21 | { |
||
22 | const ACTION_DEPLOY = 'DEPLOY'; |
||
23 | const ACTION_SKIP = 'SKIP'; |
||
24 | const ACTION_QUIT = 'QUIT'; |
||
25 | |||
26 | /** @var Executor */ |
||
27 | private $executor; |
||
28 | |||
29 | /** @var CandidateProcessor */ |
||
30 | private $processor; |
||
31 | |||
32 | /** @var HasSyntaxCorrectCheck */ |
||
33 | private $syntaxCheck; |
||
34 | |||
35 | /** @var Sql */ |
||
36 | private $sqlFormatter; |
||
37 | |||
38 | /** @var ProvisionConfig */ |
||
39 | private $config; |
||
40 | |||
41 | /** @var SymfonyStyle */ |
||
42 | private $input; |
||
43 | |||
44 | /** @var int */ |
||
45 | private $startTimestamp; |
||
46 | |||
47 | /** @var int */ |
||
48 | private $candidateIndexValue = 1; |
||
49 | |||
50 | |||
51 | /** |
||
52 | * ActionDispatcher constructor. |
||
53 | * |
||
54 | * @param Executor $executor |
||
55 | * @param CandidateProcessor $processor |
||
56 | 1 | * @param HasSyntaxCorrectCheck $check |
|
57 | * @param Sql $sqlFormatter |
||
58 | * @param ProvisionConfig $config |
||
59 | */ |
||
60 | public function __construct( |
||
74 | |||
75 | |||
76 | |||
77 | /** |
||
78 | * @param SymfonyStyle $io |
||
79 | */ |
||
80 | public function setInputOutput(SymfonyStyle $io) |
||
84 | |||
85 | |||
86 | |||
87 | /** |
||
88 | * @param Candidate[] $workingDirectoryCandidates |
||
89 | * @param int $queuedCandidatesCount |
||
90 | */ |
||
91 | public function deploy(array $workingDirectoryCandidates, $queuedCandidatesCount) |
||
103 | |||
104 | |||
105 | |||
106 | /** |
||
107 | * @param Candidate $candidate |
||
108 | */ |
||
109 | public function validate(Candidate $candidate) |
||
120 | |||
121 | |||
122 | |||
123 | public function skipSyntaxCheck() |
||
128 | |||
129 | |||
130 | |||
131 | /** |
||
132 | * @param Candidate $candidate |
||
133 | */ |
||
134 | private function ignoreCandidateHavingError(Candidate $candidate) |
||
143 | |||
144 | |||
145 | |||
146 | /** |
||
147 | * @param Candidate $candidate |
||
148 | * @param int $queuedCandidatesCount |
||
149 | */ |
||
150 | private function executeCandidateScript(Candidate $candidate, $queuedCandidatesCount) |
||
170 | |||
171 | |||
172 | |||
173 | /** |
||
174 | * @param Candidate $candidate |
||
175 | */ |
||
176 | private function deployCandidate(Candidate $candidate) |
||
196 | |||
197 | |||
198 | |||
199 | public function finalizeAndExit() |
||
212 | |||
213 | |||
214 | |||
215 | private function terminate() |
||
220 | |||
221 | |||
222 | |||
223 | /** |
||
224 | * @param Candidate $candidate |
||
225 | * @param string $action |
||
226 | */ |
||
227 | private function dispatchAction(Candidate $candidate, $action) |
||
238 | } |
||
239 |