TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
extensionmanager/Classes/Controller/ActionController.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\Controller;
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 
22 {
26  protected $installUtility;
27 
32 
37 
41  protected $managementService;
42 
46  public function injectInstallUtility(\TYPO3\CMS\Extensionmanager\Utility\InstallUtility $installUtility)
47  {
48  $this->installUtility = $installUtility;
49  }
50 
54  public function injectFileHandlingUtility(\TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility $fileHandlingUtility)
55  {
56  $this->fileHandlingUtility = $fileHandlingUtility;
57  }
58 
62  public function injectExtensionModelUtility(\TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility $extensionModelUtility)
63  {
64  $this->extensionModelUtility = $extensionModelUtility;
65  }
66 
70  public function injectManagementService(\TYPO3\CMS\Extensionmanager\Service\ExtensionManagementService $managementService)
71  {
72  $this->managementService = $managementService;
73  }
74 
80  protected function toggleExtensionInstallationStateAction($extensionKey)
81  {
83  try {
84  if (in_array($extensionKey, $installedExtensions)) {
85  // uninstall
86  $this->installUtility->uninstall($extensionKey);
87  } else {
88  // install
89  $extension = $this->extensionModelUtility->mapExtensionArrayToModel(
90  $this->installUtility->enrichExtensionWithDetails($extensionKey, false)
91  );
92  if ($this->managementService->installExtension($extension) === false) {
93  $this->redirect('unresolvedDependencies', 'List', null, ['extensionKey' => $extensionKey]);
94  }
95  }
96  } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) {
98  } catch (\TYPO3\CMS\Core\Package\Exception\PackageStatesFileNotWritableException $e) {
100  }
101  $this->redirect('index', 'List', null, [self::TRIGGER_RefreshModuleMenu => true]);
102  }
103 
111  {
112  $this->managementService->setSkipDependencyCheck(true);
113  $this->forward('toggleExtensionInstallationState', null, null, ['extensionKey' => $extensionKey]);
114  }
115 
122  protected function removeExtensionAction($extension)
123  {
124  try {
125  $this->installUtility->removeExtension($extension);
126  $this->addFlashMessage(
127  \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
128  'extensionList.remove.message',
129  'extensionmanager',
130  [
131  'extension' => $extension,
132  ]
133  )
134  );
135  } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) {
137  } catch (\TYPO3\CMS\Core\Package\Exception $e) {
139  }
140 
141  return '';
142  }
143 
149  protected function downloadExtensionZipAction($extension)
150  {
151  $fileName = $this->fileHandlingUtility->createZipFileFromExtension($extension);
152  $this->fileHandlingUtility->sendZipFileToBrowserAndDelete($fileName);
153  }
154 
161  protected function downloadExtensionDataAction($extension)
162  {
163  $error = null;
164  $sqlData = $this->installUtility->getExtensionSqlDataDump($extension);
165  $dump = $sqlData['extTables'] . $sqlData['staticSql'];
166  $fileName = $extension . '_sqlDump.sql';
167  $filePath = PATH_site . 'typo3temp/var/ExtensionManager/' . $fileName;
169  if (is_string($error)) {
170  throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException($error, 1343048718);
171  }
172  $this->fileHandlingUtility->sendSqlDumpFileToBrowserAndDelete($filePath, $fileName);
173  }
174 }
injectManagementService(\TYPO3\CMS\Extensionmanager\Service\ExtensionManagementService $managementService)
redirect($actionName, $controllerName=null, $extensionName=null, array $arguments=null, $pageUid=null, $delay=0, $statusCode=303)
forward($actionName, $controllerName=null, $extensionName=null, array $arguments=null)
injectExtensionModelUtility(\TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility $extensionModelUtility)
injectFileHandlingUtility(\TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility $fileHandlingUtility)
static translate($key, $extensionName, $arguments=null)
static writeFileToTypo3tempDir($filepath, $content)
addFlashMessage($messageBody, $messageTitle= '', $severity=\TYPO3\CMS\Core\Messaging\AbstractMessage::OK, $storeInSession=true)
injectInstallUtility(\TYPO3\CMS\Extensionmanager\Utility\InstallUtility $installUtility)