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