2 namespace TYPO3\CMS\Extensionmanager\Controller
;
5 * This file is part of the TYPO3 CMS project.
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.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
18 * Controller for handling extension related actions like
19 * installing, removing, downloading of data or files
21 class ActionController
extends AbstractController
24 * @var \TYPO3\CMS\Extensionmanager\Utility\InstallUtility
26 protected $installUtility;
29 * @var \TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility
31 protected $fileHandlingUtility;
34 * @var \TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility
36 protected $extensionModelUtility;
39 * @var \TYPO3\CMS\Extensionmanager\Service\ExtensionManagementService
41 protected $managementService;
44 * @param \TYPO3\CMS\Extensionmanager\Utility\InstallUtility $installUtility
46 public function injectInstallUtility(\TYPO3\CMS\Extensionmanager\Utility\InstallUtility
$installUtility)
48 $this->installUtility
= $installUtility;
52 * @param \TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility $fileHandlingUtility
54 public function injectFileHandlingUtility(\TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility
$fileHandlingUtility)
56 $this->fileHandlingUtility
= $fileHandlingUtility;
60 * @param \TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility $extensionModelUtility
62 public function injectExtensionModelUtility(\TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility
$extensionModelUtility)
64 $this->extensionModelUtility
= $extensionModelUtility;
68 * @param \TYPO3\CMS\Extensionmanager\Service\ExtensionManagementService $managementService
70 public function injectManagementService(\TYPO3\CMS\Extensionmanager\Service\ExtensionManagementService
$managementService)
72 $this->managementService
= $managementService;
76 * Toggle extension installation state action
78 * @param string $extensionKey
80 protected function toggleExtensionInstallationStateAction($extensionKey)
82 $installedExtensions = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::getLoadedExtensionListArray();
84 if (in_array($extensionKey, $installedExtensions)) {
86 $this->installUtility
->uninstall($extensionKey);
89 $extension = $this->extensionModelUtility
->mapExtensionArrayToModel(
90 $this->installUtility
->enrichExtensionWithDetails($extensionKey, false
)
92 if ($this->managementService
->installExtension($extension) === false
) {
93 $this->redirect('unresolvedDependencies', 'List', null
, ['extensionKey' => $extensionKey]);
96 } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
$e) {
97 $this->addFlashMessage($e->getMessage(), '', \TYPO3\CMS\Core\Messaging\FlashMessage
::ERROR
);
98 } catch (\TYPO3\CMS\Core\Package\Exception\PackageStatesFileNotWritableException
$e) {
99 $this->addFlashMessage($e->getMessage(), '', \TYPO3\CMS\Core\Messaging\FlashMessage
::ERROR
);
101 $this->redirect('index', 'List', null
, [self
::TRIGGER_RefreshModuleMenu
=> true
]);
105 * Install an extension and omit dependency checking
107 * @param string $extensionKey
110 public function installExtensionWithoutSystemDependencyCheckAction($extensionKey)
112 $this->managementService
->setSkipDependencyCheck(true
);
113 $this->forward('toggleExtensionInstallationState', null
, null
, ['extensionKey' => $extensionKey]);
117 * Remove an extension (if it is still installed, uninstall it first)
119 * @param string $extension
122 protected function removeExtensionAction($extension)
125 $this->installUtility
->removeExtension($extension);
126 $this->addFlashMessage(
127 \TYPO3\CMS\Extbase\Utility\LocalizationUtility
::translate(
128 'extensionList.remove.message',
131 'extension' => $extension,
135 } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
$e) {
136 $this->addFlashMessage($e->getMessage(), '', \TYPO3\CMS\Core\Messaging\FlashMessage
::ERROR
);
137 } catch (\TYPO3\CMS\Core\Package\Exception
$e) {
138 $this->addFlashMessage($e->getMessage(), '', \TYPO3\CMS\Core\Messaging\FlashMessage
::ERROR
);
145 * Download an extension as a zip file
147 * @param string $extension
149 protected function downloadExtensionZipAction($extension)
151 $fileName = $this->fileHandlingUtility
->createZipFileFromExtension($extension);
152 $this->fileHandlingUtility
->sendZipFileToBrowserAndDelete($fileName);
156 * Download data of an extension as sql statements
158 * @param string $extension
159 * @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
161 protected function downloadExtensionDataAction($extension)
164 $sqlData = $this->installUtility
->getExtensionSqlDataDump($extension);
165 $dump = $sqlData['extTables'] . $sqlData['staticSql'];
166 $fileName = $extension . '_sqlDump.sql';
167 $filePath = PATH_site
. 'typo3temp/ExtensionManager/' . $fileName;
168 $error = \TYPO3\CMS\Core\Utility\GeneralUtility
::writeFileToTypo3tempDir($filePath, $dump);
169 if (is_string($error)) {
170 throw new \TYPO3\CMS\Extensionmanager\Exception\
ExtensionManagerException($error, 1343048718);
172 $this->fileHandlingUtility
->sendSqlDumpFileToBrowserAndDelete($filePath, $fileName);