|
35 | 35 | use MASK\Mask\Domain\Repository\StorageRepository; |
36 | 36 | use Symfony\Component\Finder\Finder; |
37 | 37 | use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; |
| 38 | +use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; |
38 | 39 | use TYPO3\CMS\Core\Core\Environment; |
39 | 40 | use TYPO3\CMS\Core\Messaging\AbstractMessage; |
40 | 41 | use TYPO3\CMS\Core\Utility\GeneralUtility; |
@@ -181,12 +182,7 @@ public function downloadAction($vendorName, $extensionName, $elements) |
181 | 182 | */ |
182 | 183 | public function installAction($vendorName, $extensionName, $elements) |
183 | 184 | { |
184 | | - $paths = Extension::returnInstallPaths(); |
185 | | - if (empty($paths['Local']) || !file_exists($paths['Local'])) { |
186 | | - throw new \RuntimeException('Local extension install path is missing', 1500061028); |
187 | | - } |
188 | | - |
189 | | - $extensionPath = $paths['Local'] . $extensionName; |
| 185 | + $extensionPath = $this->getExtensionsPath() . $extensionName; |
190 | 186 | $files = $this->getFiles($vendorName, $extensionName, $elements); |
191 | 187 | $this->writeExtensionFilesToPath($files, $extensionPath); |
192 | 188 |
|
@@ -318,6 +314,54 @@ protected function getFiles($vendorName, $extensionName, $elements) |
318 | 314 | return $files; |
319 | 315 | } |
320 | 316 |
|
| 317 | + /** |
| 318 | + * Return the extension install path including the trailing slash. |
| 319 | + */ |
| 320 | + protected function getExtensionsPath(): string |
| 321 | + { |
| 322 | + // For non Composer installs early return the local extensions path |
| 323 | + if (!Environment::isComposerMode()) { |
| 324 | + $path = Extension::returnInstallPaths()['Local'] ?? ''; |
| 325 | + if (empty($path) || !file_exists($path)) { |
| 326 | + throw new \RuntimeException('Local extension install path is missing.', 1500061028); |
| 327 | + } |
| 328 | + |
| 329 | + return $path; |
| 330 | + } |
| 331 | + |
| 332 | + // For Composer installs the composerPathRepository setting will be |
| 333 | + // used with a fallback if possible to the local exensions path. |
| 334 | + $composerPathRepository = GeneralUtility::makeInstance(ExtensionConfiguration::class) |
| 335 | + ->get('mask_export', 'composerPathRepository') |
| 336 | + ; |
| 337 | + |
| 338 | + if ($composerPathRepository === '') { |
| 339 | + $path = Extension::returnInstallPaths()['Local'] ?? ''; |
| 340 | + |
| 341 | + $this->addFlashMessage( |
| 342 | + 'The path to the Composer path repository should be properly configured in the extension settings.', |
| 343 | + 'Warning', |
| 344 | + AbstractMessage::WARNING |
| 345 | + ); |
| 346 | + } else { |
| 347 | + if (substr($composerPathRepository, 0, 1) !== '/') { |
| 348 | + $path = Environment::getComposerRootPath() . '/' . $composerPathRepository; |
| 349 | + } else { |
| 350 | + $path = Environment::getComposerRootPath() . $composerPathRepository; |
| 351 | + } |
| 352 | + } |
| 353 | + |
| 354 | + if (empty($path) || !file_exists($path)) { |
| 355 | + throw new \RuntimeException('Path to the Composer path repository is missing. Please properly configure it in the extension settings.', 1653409378); |
| 356 | + } |
| 357 | + |
| 358 | + if (substr($path, -1) !== '/') { |
| 359 | + $path .= '/'; |
| 360 | + } |
| 361 | + |
| 362 | + return $path; |
| 363 | + } |
| 364 | + |
321 | 365 | protected function prepareConfiguration(string $vendorName, string $extensionName, array $elements) |
322 | 366 | { |
323 | 367 | $aggregatedConfiguration = $this->maskConfiguration; |
|
0 commit comments