[TASK] Provide upgradeWizard to enable adminPanel
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Updates / AdminPanelInstall.php
1 <?php
2 declare(strict_types=1);
3
4 namespace TYPO3\CMS\Install\Updates;
5
6 /*
7 * This file is part of the TYPO3 CMS project.
8 *
9 * It is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License, either version 2
11 * of the License, or any later version.
12 *
13 * For the full copyright and license information, please read the
14 * LICENSE.txt file that was distributed with this source code.
15 *
16 * The TYPO3 project - inspiring people to share!
17 */
18
19 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
20 use TYPO3\CMS\Core\Utility\GeneralUtility;
21 use TYPO3\CMS\Extbase\Object\ObjectManager;
22 use TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException;
23 use TYPO3\CMS\Extensionmanager\Utility\InstallUtility;
24
25 /**
26 * Installs EXT:adminpanel
27 */
28 class AdminPanelInstall extends AbstractUpdate
29 {
30 /**
31 * @var string
32 */
33 protected $title = 'Install extension "adminpanel"';
34
35 /**
36 * @var string
37 */
38 protected $extensionKey = 'adminpanel';
39
40 /**
41 * Checks if an update is needed
42 *
43 * @param string $description The description for the update
44 * @return bool Whether an update is needed (true) or not (false)
45 */
46 public function checkForUpdate(&$description): bool
47 {
48 $description = 'The TYPO3 admin panel was extracted to an own extension. This update installs the extension.';
49
50 if (ExtensionManagementUtility::isLoaded('adminpanel')) {
51 $this->markWizardAsDone();
52 }
53
54 $updateNeeded = false;
55 if (!$this->isWizardDone()) {
56 $updateNeeded = true;
57 }
58 return $updateNeeded;
59 }
60
61 /**
62 * Performs the update
63 *
64 * @param array $databaseQueries Queries done in this update
65 * @param string $customMessage Custom message
66 * @return bool
67 */
68 public function performUpdate(array &$databaseQueries, &$customMessage): bool
69 {
70 $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
71 $extensionInstallUtility = $objectManager->get(InstallUtility::class);
72 try {
73 $extensionInstallUtility->install('adminpanel');
74 $updateSuccessful = true;
75 $this->markWizardAsDone();
76 } catch (ExtensionManagerException $e) {
77 $updateSuccessful = false;
78 }
79 return $updateSuccessful;
80 }
81 }