TYPO3 CMS  TYPO3_7-6
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, [self::TRIGGER_RefreshModuleMenu => true]);
105  }
106 
114  {
115  $this->managementService->setSkipDependencyCheck(true);
116  $this->forward('toggleExtensionInstallationState', null, null, ['extensionKey' => $extensionKey]);
117  }
118 
125  protected function removeExtensionAction($extension)
126  {
127  try {
128  $this->installUtility->removeExtension($extension);
129  $this->addFlashMessage(
130  \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
131  'extensionList.remove.message',
132  'extensionmanager',
133  [
134  'extension' => $extension,
135  ]
136  )
137  );
138  } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) {
140  } catch (\TYPO3\CMS\Core\Package\Exception $e) {
142  }
143 
144  return '';
145  }
146 
152  protected function downloadExtensionZipAction($extension)
153  {
154  $fileName = $this->fileHandlingUtility->createZipFileFromExtension($extension);
155  $this->fileHandlingUtility->sendZipFileToBrowserAndDelete($fileName);
156  }
157 
164  protected function downloadExtensionDataAction($extension)
165  {
166  $error = null;
167  $sqlData = $this->installUtility->getExtensionSqlDataDump($extension);
168  $dump = $sqlData['extTables'] . $sqlData['staticSql'];
169  $fileName = $extension . '_sqlDump.sql';
170  $filePath = PATH_site . 'typo3temp/ExtensionManager/' . $fileName;
172  if (is_string($error)) {
173  throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException($error, 1343048718);
174  }
175  $this->fileHandlingUtility->sendSqlDumpFileToBrowserAndDelete($filePath, $fileName);
176  }
177 
183  protected function reloadExtensionDataAction($extension)
184  {
185  $extension = $this->installUtility->enrichExtensionWithDetails($extension, false);
186  $registryKey = $extension['siteRelPath'] . 'ext_tables_static+adt.sql';
187 
188  $registry = GeneralUtility::makeInstance(Registry::class);
189  $registry->remove('extensionDataImport', $registryKey);
190 
191  $this->installUtility->processDatabaseUpdates($extension);
192 
193  $this->redirect('index', 'List');
194  }
195 }
static translate($key, $extensionName, $arguments=null)
static writeFileToTypo3tempDir($filepath, $content)
redirect($actionName, $controllerName=null, $extensionName=null, array $arguments=null, $pageUid=null, $delay=0, $statusCode=303)
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)