TYPO3 CMS  TYPO3_8-7
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 
25 {
29  protected $installUtility;
30 
35 
40 
44  protected $managementService;
45 
49  public function injectInstallUtility(\TYPO3\CMS\Extensionmanager\Utility\InstallUtility $installUtility)
50  {
51  $this->installUtility = $installUtility;
52  }
53 
57  public function injectFileHandlingUtility(\TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility $fileHandlingUtility)
58  {
59  $this->fileHandlingUtility = $fileHandlingUtility;
60  }
61 
65  public function injectExtensionModelUtility(\TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility $extensionModelUtility)
66  {
67  $this->extensionModelUtility = $extensionModelUtility;
68  }
69 
73  public function injectManagementService(\TYPO3\CMS\Extensionmanager\Service\ExtensionManagementService $managementService)
74  {
75  $this->managementService = $managementService;
76  }
77 
83  protected function toggleExtensionInstallationStateAction($extensionKey)
84  {
86  try {
87  if (in_array($extensionKey, $installedExtensions)) {
88  // uninstall
89  $this->installUtility->uninstall($extensionKey);
90  } else {
91  // install
92  $extension = $this->extensionModelUtility->mapExtensionArrayToModel(
93  $this->installUtility->enrichExtensionWithDetails($extensionKey, false)
94  );
95  if ($this->managementService->installExtension($extension) === false) {
96  $this->redirect('unresolvedDependencies', 'List', null, ['extensionKey' => $extensionKey]);
97  }
98  }
99  } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) {
101  } catch (\TYPO3\CMS\Core\Package\Exception\PackageStatesFileNotWritableException $e) {
103  }
104  $this->redirect('index', 'List', null, [
105  self::TRIGGER_RefreshModuleMenu => true,
106  self::TRIGGER_RefreshTopbar => true
107  ]);
108  }
109 
116  {
117  $this->managementService->setSkipDependencyCheck(true);
118  $this->forward('toggleExtensionInstallationState', null, null, ['extensionKey' => $extensionKey]);
119  }
120 
127  protected function removeExtensionAction($extension)
128  {
129  try {
130  $this->installUtility->removeExtension($extension);
131  $this->addFlashMessage(
132  \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
133  'extensionList.remove.message',
134  'extensionmanager',
135  [
136  'extension' => $extension,
137  ]
138  )
139  );
140  } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) {
142  } catch (\TYPO3\CMS\Core\Package\Exception $e) {
144  }
145 
146  return '';
147  }
148 
154  protected function downloadExtensionZipAction($extension)
155  {
156  $fileName = $this->fileHandlingUtility->createZipFileFromExtension($extension);
157  $this->fileHandlingUtility->sendZipFileToBrowserAndDelete($fileName);
158  }
159 
166  protected function downloadExtensionDataAction($extension)
167  {
168  $error = null;
169  $sqlData = $this->installUtility->getExtensionSqlDataDump($extension);
170  $dump = $sqlData['extTables'] . $sqlData['staticSql'];
171  $fileName = $extension . '_sqlDump.sql';
172  $filePath = PATH_site . 'typo3temp/var/ExtensionManager/' . $fileName;
174  if (is_string($error)) {
175  throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException($error, 1343048718);
176  }
177  $this->fileHandlingUtility->sendSqlDumpFileToBrowserAndDelete($filePath, $fileName);
178  }
179 
185  protected function reloadExtensionDataAction($extension)
186  {
187  $extension = $this->installUtility->enrichExtensionWithDetails($extension, false);
188  $registryKey = $extension['siteRelPath'] . 'ext_tables_static+adt.sql';
189 
190  $registry = GeneralUtility::makeInstance(Registry::class);
191  $registry->remove('extensionDataImport', $registryKey);
192 
193  $this->installUtility->processExtensionSetup($extension['key']);
194 
195  $this->redirect('index', 'List');
196  }
197 }
static writeFileToTypo3tempDir($filepath, $content)
static translate($key, $extensionName=null, $arguments=null)
redirect($actionName, $controllerName=null, $extensionName=null, array $arguments=null, $pageUid=null, $delay=0, $statusCode=303)
static makeInstance($className,... $constructorArguments)
injectExtensionModelUtility(\TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility $extensionModelUtility)
injectManagementService(\TYPO3\CMS\Extensionmanager\Service\ExtensionManagementService $managementService)
forward($actionName, $controllerName=null, $extensionName=null, array $arguments=null)
injectFileHandlingUtility(\TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility $fileHandlingUtility)
addFlashMessage($messageBody, $messageTitle='', $severity=\TYPO3\CMS\Core\Messaging\AbstractMessage::OK, $storeInSession=true)
injectInstallUtility(\TYPO3\CMS\Extensionmanager\Utility\InstallUtility $installUtility)