[FEATURE] Uninstall broken ext in install tool
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Controller / Action / Ajax / UninstallExtension.php
1 <?php
2 namespace TYPO3\CMS\Install\Controller\Action\Ajax;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2013 Susanne Moog <typo3@susanne-moog.de>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 use TYPO3\CMS\Install\Controller\Action;
28 use TYPO3\CMS\Core\Utility;
29
30 /**
31 * Uninstall Extensions
32 *
33 * Used for uninstalling an extension (or multiple) via an ajax request.
34 * Warning! No dependency checking is done here, the extension is just removed
35 * from the extension list.
36 *
37 * If you use this class you have to take care of clearing the cache afterwards,
38 * it's not done here because for fully clearing the cache you need a reload
39 * to take care of changed cache configurations due to no longer installed extensions.
40 * Use the clearCache ajax action afterwards.
41 */
42 class UninstallExtension extends Action\AbstractAction implements Action\ActionInterface {
43
44 /**
45 * Handle this action
46 *
47 * @return string content
48 */
49 public function handle() {
50 $this->initialize();
51 return $this->uninstallExtensions();
52 }
53
54 /**
55 * Uninstall one or multiple extensions
56 * Extension keys are read from get vars, more than one extension has to be comma separated
57 * Cache is cleared "hard" after uninstalling
58 *
59 * @return string
60 */
61 public function uninstallExtensions() {
62 $getVars = Utility\GeneralUtility::_GET('install');
63 if (isset($getVars['uninstallExtension']) && isset($getVars['uninstallExtension']['extensions'])) {
64 $extensionsToUninstall = Utility\GeneralUtility::trimExplode(',', $getVars['uninstallExtension']['extensions']);
65 foreach ($extensionsToUninstall as $extension) {
66 if (Utility\ExtensionManagementUtility::isLoaded($extension)) {
67 Utility\ExtensionManagementUtility::unloadExtension($extension);
68 }
69 }
70 }
71 return 'OK';
72 }
73
74 }
75
76 ?>