1 | <?php |
||
33 | class InstallTask extends AbstractComposerCommandTask |
||
34 | { |
||
35 | /** |
||
36 | * Constant for the package name key. |
||
37 | */ |
||
38 | const SETTING_PACKAGE = 'package'; |
||
39 | |||
40 | /** |
||
41 | * Constant for the package version key. |
||
42 | */ |
||
43 | const SETTING_VERSION = 'version'; |
||
44 | |||
45 | /** |
||
46 | * Constant for the destination dir key. |
||
47 | */ |
||
48 | const SETTING_DESTINATION_DIR = 'dest-dir'; |
||
49 | |||
50 | /** |
||
51 | * Constant for the repository url. |
||
52 | */ |
||
53 | const SETTING_REPOSITORY_URL = 'repository-url'; |
||
54 | |||
55 | /** |
||
56 | * The temporary directory to use. |
||
57 | * |
||
58 | * @var string |
||
59 | */ |
||
60 | private $tempDir; |
||
61 | |||
62 | /** |
||
63 | * The environment variable storage. |
||
64 | * |
||
65 | * @var string|null |
||
66 | */ |
||
67 | private $previousEnvVariable; |
||
68 | |||
69 | /** |
||
70 | * The previous working directory. |
||
71 | * |
||
72 | * @var string |
||
73 | */ |
||
74 | private $previousWorkingDir; |
||
75 | |||
76 | /** |
||
77 | * The list of folders to remove after the installation was complete. |
||
78 | * |
||
79 | * @var string[] |
||
80 | */ |
||
81 | private $folders; |
||
82 | |||
83 | /** |
||
84 | * {@inheritDoc} |
||
85 | */ |
||
86 | public function getType() |
||
90 | |||
91 | /** |
||
92 | * {@inheritDoc} |
||
93 | * |
||
94 | * @throws \RuntimeException When the project directory is not empty or when the installation was not successful. |
||
95 | */ |
||
96 | public function doPerform() |
||
119 | |||
120 | /** |
||
121 | * Prepare a temporary directory. |
||
122 | * |
||
123 | * @return void |
||
124 | * |
||
125 | * @throws \RuntimeException When an error occurred. |
||
126 | */ |
||
127 | private function prepareTmpDir() |
||
138 | |||
139 | /** |
||
140 | * {@inheritDoc} |
||
141 | */ |
||
142 | protected function prepareCommand() |
||
146 | |||
147 | /** |
||
148 | * {@inheritDoc} |
||
149 | */ |
||
150 | protected function prepareInput() |
||
174 | |||
175 | /** |
||
176 | * Move the installed files to their intended destination. |
||
177 | * |
||
178 | * @return void |
||
179 | */ |
||
180 | private function moveFiles() |
||
200 | |||
201 | /** |
||
202 | * Move a single file or folder. |
||
203 | * |
||
204 | * @param SplFileInfo $file The file to move. |
||
205 | * |
||
206 | * @param string $targetDir The destination directory. |
||
207 | * |
||
208 | * @param bool $logging Flag determining if actions shall get logged. |
||
209 | * |
||
210 | * @param IOInterface $ioHandler The io handler to log to. |
||
211 | * |
||
212 | * @return void |
||
213 | * |
||
214 | * @throws \RuntimeException When an unknown file type has been encountered. |
||
215 | */ |
||
216 | private function moveFile(SplFileInfo $file, $targetDir, $logging, $ioHandler) |
||
268 | |||
269 | /** |
||
270 | * Check if we may install into the destination directory. |
||
271 | * |
||
272 | * @return bool |
||
273 | */ |
||
274 | private function mayInstall() |
||
280 | |||
281 | /** |
||
282 | * Save the current environment variable and working directory. |
||
283 | * |
||
284 | * @return void |
||
285 | */ |
||
286 | private function preserveEnvironment() |
||
293 | |||
294 | /** |
||
295 | * Restore the current environment variable and working directory. |
||
296 | * |
||
297 | * @return void |
||
298 | */ |
||
299 | private function restoreEnvironment() |
||
304 | } |
||
305 |