18 use Symfony\Component\Console\Output\OutputInterface;
35 protected $repositoryUrl =
'https://typo3.org/fileadmin/ter/@filename';
76 $updateSuccessful =
true;
78 $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
81 $extensionListUtility = $objectManager->get(ListUtility::class);
82 $availableExtensions = $extensionListUtility->getAvailableExtensions();
85 $isExtensionAvailable = !empty($availableExtensions[$extensionKey]);
88 if (!$isComposerMode && !$isExtensionAvailable) {
90 $extensionTerUtility = $objectManager->get(TerUtility::class);
92 if (empty($t3xContent)) {
93 $updateSuccessful =
false;
94 $this->output->writeln(
'<error>The extension ' . $extensionKey .
' could not be downloaded.</error>');
96 $t3xExtracted = $extensionTerUtility->decodeExchangeData($t3xContent);
97 if (empty($t3xExtracted) || !is_array($t3xExtracted) || empty($t3xExtracted[
'extKey'])) {
98 $updateSuccessful =
false;
99 $this->output->writeln(
'<error>The extension ' . $extensionKey .
' could not be extracted.</error>');
103 $extensionFileHandlingUtility = $objectManager->get(FileHandlingUtility::class);
104 $extensionFileHandlingUtility->unpackExtensionFromExtensionDataArray($t3xExtracted);
107 $extensionListUtility->reloadAvailableExtensions();
110 if ($isComposerMode && !$isExtensionAvailable) {
111 $updateSuccessful =
false;
112 $this->output->writeln(
113 '<warning>The extension ' . $extensionKey
114 .
' can not be downloaded since Composer is used for package management. Please require this '
120 if ($updateSuccessful) {
122 $extensionInstallUtility = $objectManager->get(InstallUtility::class);
123 $extensionInstallUtility->install($extensionKey);
126 return $updateSuccessful;
139 if (empty($extensionKey) || empty($version)) {
140 throw new \InvalidArgumentException(
141 'No extension key for fetching an extension was given.',
146 $filename = $extensionKey[0] .
'/' . $extensionKey[1] .
'/' . $extensionKey .
'_' . $version .
'.t3x';
147 $url = str_replace(
'@filename', $filename, $this->repositoryUrl);
162 protected function fetchUrl($url):
string
165 throw new \InvalidArgumentException(
166 'No URL for downloading an extension given.',
171 $fileContent = GeneralUtility::getUrl($url);
174 if ($fileContent ===
false) {
175 throw new \RuntimeException(
176 'Can not fetch URL "' . $url .
'". Possible reasons are network problems or misconfiguration.',