‪TYPO3CMS  9.5
ActionController.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
19 
26 {
30  protected ‪$installUtility;
31 
35  protected ‪$fileHandlingUtility;
36 
40  protected ‪$extensionModelUtility;
41 
45  protected ‪$managementService;
46 
50  public function ‪injectInstallUtility(\‪TYPO3\CMS\Extensionmanager\Utility\InstallUtility ‪$installUtility)
51  {
52  $this->installUtility = ‪$installUtility;
53  }
54 
58  public function ‪injectFileHandlingUtility(\‪TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility ‪$fileHandlingUtility)
59  {
60  $this->fileHandlingUtility = ‪$fileHandlingUtility;
61  }
62 
67  {
68  $this->extensionModelUtility = ‪$extensionModelUtility;
69  }
70 
74  public function ‪injectManagementService(\‪TYPO3\CMS\Extensionmanager\Service\ExtensionManagementService ‪$managementService)
75  {
76  $this->managementService = ‪$managementService;
77  }
78 
84  protected function ‪toggleExtensionInstallationStateAction($extensionKey)
85  {
87  try {
88  if (in_array($extensionKey, $installedExtensions)) {
89  // uninstall
90  $this->installUtility->uninstall($extensionKey);
91  } else {
92  // install
93  $extension = $this->extensionModelUtility->mapExtensionArrayToModel(
94  $this->installUtility->enrichExtensionWithDetails($extensionKey, false)
95  );
96  if ($this->managementService->installExtension($extension) === false) {
97  $this->‪redirect('unresolvedDependencies', 'List', null, ['extensionKey' => $extensionKey]);
98  }
99  }
100  } catch (\‪TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) {
101  $this->‪addFlashMessage($e->getMessage(), '', \‪TYPO3\CMS\Core\Messaging\‪FlashMessage::ERROR);
102  } catch (\‪TYPO3\CMS\Core\Package\Exception\PackageStatesFileNotWritableException $e) {
103  $this->‪addFlashMessage($e->getMessage(), '', \‪TYPO3\CMS\Core\Messaging\‪FlashMessage::ERROR);
104  }
105  $this->‪redirect('index', 'List', null, [
106  self::TRIGGER_RefreshModuleMenu => true,
107  self::TRIGGER_RefreshTopbar => true
108  ]);
109  }
110 
116  public function ‪installExtensionWithoutSystemDependencyCheckAction($extensionKey)
117  {
118  $this->managementService->setSkipDependencyCheck(true);
119  $this->‪forward('toggleExtensionInstallationState', null, null, ['extensionKey' => $extensionKey]);
120  }
121 
128  protected function ‪removeExtensionAction($extension)
129  {
130  try {
131  if (\‪TYPO3\CMS\Core\Core\‪Environment::isComposerMode()) {
132  throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException(
133  'The system is set to composer mode. You are not allowed to remove any extension.',
134  1590314046
135  );
136  }
137 
138  $this->installUtility->removeExtension($extension);
139  $this->‪addFlashMessage(
141  'extensionList.remove.message',
142  'extensionmanager',
143  [
144  'extension' => $extension,
145  ]
146  )
147  );
148  } catch (\‪TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) {
149  $this->‪addFlashMessage($e->getMessage(), '', \‪TYPO3\CMS\Core\Messaging\‪FlashMessage::ERROR);
150  } catch (\‪TYPO3\CMS\Core\Package\Exception $e) {
151  $this->‪addFlashMessage($e->getMessage(), '', \‪TYPO3\CMS\Core\Messaging\‪FlashMessage::ERROR);
152  }
153 
154  return '';
155  }
156 
162  protected function ‪downloadExtensionZipAction($extension)
163  {
164  $fileName = $this->fileHandlingUtility->createZipFileFromExtension($extension);
165  $this->fileHandlingUtility->sendZipFileToBrowserAndDelete($fileName);
166  }
167 
173  protected function ‪reloadExtensionDataAction($extension)
174  {
175  $extension = $this->installUtility->enrichExtensionWithDetails($extension, false);
176  $registryKey = $extension['siteRelPath'] . 'ext_tables_static+adt.sql';
177 
178  $registry = GeneralUtility::makeInstance(Registry::class);
179  $registry->remove('extensionDataImport', $registryKey);
180 
181  $this->installUtility->processExtensionSetup($extension['key']);
182 
183  $this->‪redirect('index', 'List');
184  }
185 }
‪TYPO3\CMS\Extensionmanager\Controller\ActionController\removeExtensionAction
‪string removeExtensionAction($extension)
Definition: ActionController.php:124
‪TYPO3\CMS\Extensionmanager\Controller\ActionController\injectInstallUtility
‪injectInstallUtility(\TYPO3\CMS\Extensionmanager\Utility\InstallUtility $installUtility)
Definition: ActionController.php:46
‪TYPO3\CMS\Extensionmanager\Controller\ActionController\injectFileHandlingUtility
‪injectFileHandlingUtility(\TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility $fileHandlingUtility)
Definition: ActionController.php:54
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:4
‪TYPO3
‪TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility
Definition: ExtensionModelUtility.php:22
‪TYPO3\CMS\Core\Registry
Definition: Registry.php:32
‪TYPO3\CMS\Extensionmanager\Controller
Definition: AbstractController.php:2
‪TYPO3\CMS\Extensionmanager\Controller\ActionController\reloadExtensionDataAction
‪reloadExtensionDataAction($extension)
Definition: ActionController.php:169
‪TYPO3\CMS\Extensionmanager\Controller\ActionController\toggleExtensionInstallationStateAction
‪toggleExtensionInstallationStateAction($extensionKey)
Definition: ActionController.php:80
‪TYPO3\CMS\Extensionmanager\Controller\ActionController\installExtensionWithoutSystemDependencyCheckAction
‪installExtensionWithoutSystemDependencyCheckAction($extensionKey)
Definition: ActionController.php:112
‪TYPO3\CMS\Extensionmanager\Controller\ActionController\$installUtility
‪TYPO3 CMS Extensionmanager Utility InstallUtility $installUtility
Definition: ActionController.php:29
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate
‪static string null translate($key, $extensionName=null, $arguments=null, string $languageKey=null, array $alternativeLanguageKeys=null)
Definition: LocalizationUtility.php:63
‪TYPO3\CMS\Extbase\Mvc\Controller\AbstractController\redirect
‪redirect($actionName, $controllerName=null, $extensionName=null, array $arguments=null, $pageUid=null, $delay=0, $statusCode=303)
Definition: AbstractController.php:284
‪TYPO3\CMS\Extensionmanager\Controller\ActionController\$fileHandlingUtility
‪TYPO3 CMS Extensionmanager Utility FileHandlingUtility $fileHandlingUtility
Definition: ActionController.php:33
‪TYPO3\CMS\Extensionmanager\Exception
Definition: Exception.php:23
‪TYPO3\CMS\Extensionmanager\Controller\ActionController\injectExtensionModelUtility
‪injectExtensionModelUtility(\TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility $extensionModelUtility)
Definition: ActionController.php:62
‪TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
Definition: ExtensionManagerException.php:23
‪TYPO3\CMS\Extensionmanager\Controller\ActionController
Definition: ActionController.php:26
‪TYPO3\CMS\Extensionmanager\Controller\AbstractController
Definition: AbstractController.php:22
‪TYPO3\CMS\Core\Core\Environment\isComposerMode
‪static bool isComposerMode()
Definition: Environment.php:117
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\getLoadedExtensionListArray
‪static array getLoadedExtensionListArray()
Definition: ExtensionManagementUtility.php:1909
‪TYPO3\CMS\Extensionmanager\Controller\ActionController\$managementService
‪TYPO3 CMS Extensionmanager Service ExtensionManagementService $managementService
Definition: ActionController.php:41
‪TYPO3\CMS\Extensionmanager\Controller\ActionController\injectManagementService
‪injectManagementService(\TYPO3\CMS\Extensionmanager\Service\ExtensionManagementService $managementService)
Definition: ActionController.php:70
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Extensionmanager\Controller\ActionController\downloadExtensionZipAction
‪downloadExtensionZipAction($extension)
Definition: ActionController.php:158
‪TYPO3\CMS\Extbase\Mvc\Controller\AbstractController\addFlashMessage
‪addFlashMessage($messageBody, $messageTitle='', $severity=\TYPO3\CMS\Core\Messaging\AbstractMessage::OK, $storeInSession=true)
Definition: AbstractController.php:154
‪TYPO3\CMS\Core\Messaging\AbstractMessage\ERROR
‪const ERROR
Definition: AbstractMessage.php:29
‪TYPO3\CMS\Extbase\Mvc\Controller\AbstractController\forward
‪forward($actionName, $controllerName=null, $extensionName=null, array $arguments=null)
Definition: AbstractController.php:247
‪TYPO3\CMS\Extensionmanager\Controller\ActionController\$extensionModelUtility
‪TYPO3 CMS Extensionmanager Utility ExtensionModelUtility $extensionModelUtility
Definition: ActionController.php:37