‪TYPO3CMS  ‪main
AbstractDownloadExtensionUpdate.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Symfony\Component\Console\Output\OutputInterface;
32 
37 {
38  protected OutputInterface ‪$output;
40 
45 
47  {
48  $this->fileHandlingUtility = ‪$fileHandlingUtility;
49  }
50 
52  {
53  $this->listUtility = ‪$listUtility;
54  }
55 
57  {
58  $this->installUtility = ‪$installUtility;
59  }
60 
62  {
63  $this->remoteRegistry = ‪$remoteRegistry;
64  }
65 
66  public function ‪setOutput(OutputInterface ‪$output): void
67  {
68  $this->output = ‪$output;
69  }
70 
75  public function ‪executeUpdate(): bool
76  {
77  return $this->‪installExtension($this->extension);
78  }
79 
88  {
89  $updateSuccessful = true;
90 
91  $availableExtensions = $this->listUtility->getAvailableExtensions();
92 
93  $extensionKey = ‪$extension->‪getKey();
94  $isExtensionAvailable = !empty($availableExtensions[$extensionKey]);
95  $isComposerMode = ‪Environment::isComposerMode();
96 
97  if (!$isComposerMode && !$isExtensionAvailable) {
98  if ($this->remoteRegistry->hasDefaultRemote()) {
99  $terRemote = $this->remoteRegistry->getDefaultRemote();
100  try {
101  $terRemote->downloadExtension($extensionKey, ‪$extension->‪getVersionString(), $this->fileHandlingUtility);
102  } catch (‪DownloadFailedException) {
103  $updateSuccessful = false;
104  $this->output->writeln('<error>The extension ' . $extensionKey . ' could not be downloaded.</error>');
106  $updateSuccessful = false;
107  $this->output->writeln('<error>The extension ' . $extensionKey . ' could not be extracted.</error>');
108  }
109  } else {
110  $updateSuccessful = false;
111  $this->output->writeln(
112  '<error>The extension ' . $extensionKey . ' could not be downloaded because no remote is available.</error>'
113  );
114  }
115  // The listUtility now needs to have the regenerated list of packages
116  $this->listUtility->reloadAvailableExtensions();
117  }
118 
119  if ($isComposerMode && !$isExtensionAvailable) {
120  $updateSuccessful = false;
121  $this->output->writeln(
122  '<warning>The extension ' . $extensionKey
123  . ' can not be downloaded since Composer is used for package management. Please require this '
124  . 'extension as package via Composer: "composer require ' . ‪$extension->‪getComposerName()
125  . ':^' . ‪$extension->‪getVersionString() . '"</warning>'
126  );
127  }
128 
129  if ($updateSuccessful) {
130  $this->installUtility->install($extensionKey);
131  }
132 
133  return $updateSuccessful;
134  }
135 }
‪TYPO3\CMS\Extensionmanager\Updates\AbstractDownloadExtensionUpdate\installExtension
‪bool installExtension(ExtensionModel $extension)
Definition: AbstractDownloadExtensionUpdate.php:87
‪TYPO3\CMS\Extensionmanager\Updates\AbstractDownloadExtensionUpdate\executeUpdate
‪executeUpdate()
Definition: AbstractDownloadExtensionUpdate.php:75
‪TYPO3\CMS\Extensionmanager\Updates\AbstractDownloadExtensionUpdate\injectListUtility
‪injectListUtility(ListUtility $listUtility)
Definition: AbstractDownloadExtensionUpdate.php:51
‪TYPO3\CMS\Extensionmanager\Updates\AbstractDownloadExtensionUpdate\$extension
‪ExtensionModel $extension
Definition: AbstractDownloadExtensionUpdate.php:39
‪TYPO3\CMS\Extensionmanager\Updates\AbstractDownloadExtensionUpdate\injectRemoteRegistry
‪injectRemoteRegistry(RemoteRegistry $remoteRegistry)
Definition: AbstractDownloadExtensionUpdate.php:61
‪TYPO3\CMS\Extensionmanager\Updates\AbstractDownloadExtensionUpdate\$remoteRegistry
‪RemoteRegistry $remoteRegistry
Definition: AbstractDownloadExtensionUpdate.php:44
‪TYPO3\CMS\Extensionmanager\Updates\AbstractDownloadExtensionUpdate\$fileHandlingUtility
‪FileHandlingUtility $fileHandlingUtility
Definition: AbstractDownloadExtensionUpdate.php:41
‪TYPO3\CMS\Core\Core\Environment\isComposerMode
‪static isComposerMode()
Definition: Environment.php:137
‪TYPO3\CMS\Install\Updates\ChattyInterface
Definition: ChattyInterface.php:26
‪TYPO3\CMS\Extensionmanager\Updates\ExtensionModel\getVersionString
‪getVersionString()
Definition: ExtensionModel.php:51
‪TYPO3\CMS\Extensionmanager\Utility\ListUtility
Definition: ListUtility.php:41
‪TYPO3\CMS\Extensionmanager\Updates\AbstractDownloadExtensionUpdate
Definition: AbstractDownloadExtensionUpdate.php:37
‪TYPO3\CMS\Extensionmanager\Remote\VerificationFailedException
Definition: VerificationFailedException.php:25
‪TYPO3\CMS\Extensionmanager\Updates\ExtensionModel
Definition: ExtensionModel.php:27
‪TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility
Definition: FileHandlingUtility.php:40
‪TYPO3\CMS\Extensionmanager\Utility\InstallUtility
Definition: InstallUtility.php:40
‪TYPO3\CMS\Extensionmanager\Updates\AbstractDownloadExtensionUpdate\injectFileHandlingUtility
‪injectFileHandlingUtility(FileHandlingUtility $fileHandlingUtility)
Definition: AbstractDownloadExtensionUpdate.php:46
‪TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
Definition: ExtensionManagerException.php:25
‪TYPO3\CMS\Extensionmanager\Updates\AbstractDownloadExtensionUpdate\setOutput
‪setOutput(OutputInterface $output)
Definition: AbstractDownloadExtensionUpdate.php:66
‪TYPO3\CMS\Extensionmanager\Updates\AbstractDownloadExtensionUpdate\$output
‪OutputInterface $output
Definition: AbstractDownloadExtensionUpdate.php:38
‪TYPO3\CMS\Install\Updates\UpgradeWizardInterface
Definition: UpgradeWizardInterface.php:24
‪TYPO3\CMS\Extensionmanager\Updates\AbstractDownloadExtensionUpdate\$listUtility
‪ListUtility $listUtility
Definition: AbstractDownloadExtensionUpdate.php:42
‪TYPO3\CMS\Extensionmanager\Updates\AbstractDownloadExtensionUpdate\$installUtility
‪InstallUtility $installUtility
Definition: AbstractDownloadExtensionUpdate.php:43
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:41
‪TYPO3\CMS\Extensionmanager\Updates\ExtensionModel\getKey
‪getKey()
Definition: ExtensionModel.php:41
‪TYPO3\CMS\Extensionmanager\Updates\ExtensionModel\getComposerName
‪getComposerName()
Definition: ExtensionModel.php:56
‪TYPO3\CMS\Extensionmanager\Remote\DownloadFailedException
Definition: DownloadFailedException.php:25
‪TYPO3\CMS\Install\Updates\ConfirmableInterface
Definition: ConfirmableInterface.php:24
‪TYPO3\CMS\Extensionmanager\Remote\RemoteRegistry
Definition: RemoteRegistry.php:26
‪TYPO3\CMS\Extensionmanager\Updates
Definition: AbstractDownloadExtensionUpdate.php:18
‪TYPO3\CMS\Extensionmanager\Updates\AbstractDownloadExtensionUpdate\injectInstallUtility
‪injectInstallUtility(InstallUtility $installUtility)
Definition: AbstractDownloadExtensionUpdate.php:56