Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 49 additions & 6 deletions Classes/Controller/ExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
use MASK\Mask\Domain\Repository\StorageRepository;
use Symfony\Component\Finder\Finder;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand Down Expand Up @@ -181,12 +182,7 @@ public function downloadAction($vendorName, $extensionName, $elements)
*/
public function installAction($vendorName, $extensionName, $elements)
{
$paths = Extension::returnInstallPaths();
if (empty($paths['Local']) || !file_exists($paths['Local'])) {
throw new \RuntimeException('Local extension install path is missing', 1500061028);
}

$extensionPath = $paths['Local'] . $extensionName;
$extensionPath = $this->getExtensionsPath() . $extensionName;
$files = $this->getFiles($vendorName, $extensionName, $elements);
$this->writeExtensionFilesToPath($files, $extensionPath);

Expand Down Expand Up @@ -318,6 +314,53 @@ protected function getFiles($vendorName, $extensionName, $elements)
return $files;
}

/**
* Return the extension install path including the trailing slash.
*/
protected function getExtensionsPath(): string
{
// For non Composer installs early return the local extensions path
if (!Environment::isComposerMode()) {
$path = Extension::returnInstallPaths()['Local'] ?? '';
if (empty($path) || !file_exists($path)) {
throw new \RuntimeException('Local extension install path is missing.', 1500061028);
}

return $path;
}

// For Composer installs the composerPathRepository setting will be
// used with a fallback if possible to the local exensions path.
$composerPathRepository = GeneralUtility::makeInstance(ExtensionConfiguration::class)
->get('mask_export', 'composerPathRepository');

if ($composerPathRepository === '') {
$path = Extension::returnInstallPaths()['Local'] ?? '';

$this->addFlashMessage(
'The path to the Composer path repository should be properly configured in the extension settings.',
'Warning',
AbstractMessage::WARNING
);
} else {
if (substr($composerPathRepository, 0, 1) !== '/') {
$path = Environment::getComposerRootPath() . '/' . $composerPathRepository;
} else {
$path = Environment::getComposerRootPath() . $composerPathRepository;
}
}

if (empty($path) || !file_exists($path)) {
throw new \RuntimeException('Path to the Composer path repository is missing. Please properly configure it in the extension settings.', 1653409378);
}

if (substr($path, -1) !== '/') {
$path .= '/';
}

return $path;
}

protected function prepareConfiguration(string $vendorName, string $extensionName, array $elements)
{
$aggregatedConfiguration = $this->maskConfiguration;
Expand Down
2 changes: 2 additions & 0 deletions ext_conf_template.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# cat=Settings; type=string; label=Composer path repository: If set, this path will be used as export destination relative to the Composer root directory. Mandatory for typo3/cms-composer-installers v4 or higher. E.g. src/extensions
composerPathRepository =