‪TYPO3CMS  9.5
UpgradeWizardListCommand.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
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 Symfony\Component\Console\Command\Command;
20 use Symfony\Component\Console\Input\InputInterface;
21 use Symfony\Component\Console\Input\InputOption;
22 use Symfony\Component\Console\Output\OutputInterface;
23 use Symfony\Component\Console\Style\SymfonyStyle;
30 
36 class ‪UpgradeWizardListCommand extends Command
37 {
42 
46  private ‪$output;
47 
51  private ‪$input;
52 
56  protected function ‪bootstrap(): void
57  {
62  ‪Bootstrap::initializeBackendUser(CommandLineUserAuthentication::class);
64  }
65 
69  protected function ‪configure()
70  {
71  $this->setDescription('List available upgrade wizards.')
72  ->addOption(
73  'all',
74  'a',
75  InputOption::VALUE_NONE,
76  'Include wizards already done.'
77  );
78  }
79 
87  protected function ‪execute(InputInterface ‪$input, OutputInterface ‪$output)
88  {
89  $this->output = new SymfonyStyle(‪$input, ‪$output);
90  $this->input = ‪$input;
91  $this->‪bootstrap();
92  $this->upgradeWizardsService = new ‪UpgradeWizardsService();
93 
94  $result = 0;
95  $wizards = [];
96  $all = ‪$input->getOption('all');
97  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'] as $identifier => $wizardToExecute) {
98  $upgradeWizard = $this->‪getWizard($wizardToExecute, $identifier, (bool)$all);
99  if ($upgradeWizard !== null) {
100  $wizardInfo = [
101  'identifier' => $upgradeWizard->getIdentifier(),
102  'title' => $upgradeWizard->getTitle(),
103  'description' => wordwrap($upgradeWizard->getDescription()),
104  ];
105  if ($all === true) {
106  $wizardInfo['status'] = $this->upgradeWizardsService->isWizardDone($identifier) ? 'DONE' : 'AVAILABLE';
107  }
108  $wizards[] = $wizardInfo;
109  }
110  }
111  if (empty($wizards)) {
112  $this->output->success('No wizards available.');
113  } else {
114  if ($all === true) {
115  $this->output->table(['Identifier', 'Title', 'Description', 'Status'], $wizards);
116  } else {
117  $this->output->table(['Identifier', 'Title', 'Description'], $wizards);
118  }
119  }
120  return $result;
121  }
122 
132  protected function ‪getWizard(string $className, string $identifier, $all = false): ?‪UpgradeWizardInterface
133  {
134  // already done
135  if (!$all && $this->upgradeWizardsService->isWizardDone($identifier)) {
136  return null;
137  }
138 
139  $wizardInstance = GeneralUtility::makeInstance($className);
140  if ($wizardInstance instanceof ‪ChattyInterface) {
141  $wizardInstance->setOutput($this->output);
142  }
143 
144  if (!($wizardInstance instanceof ‪UpgradeWizardInterface)) {
145  return null;
146  }
147 
148  return !$all ? $wizardInstance->updateNecessary() ? $wizardInstance : null : $wizardInstance;
149  }
150 }
‪TYPO3\CMS\Core\Core\Bootstrap\loadBaseTca
‪static Bootstrap null loadBaseTca(bool $allowCaching=true, FrontendInterface $coreCache=null)
Definition: Bootstrap.php:832
‪TYPO3\CMS\Core\Core\Bootstrap\unsetReservedGlobalVariables
‪static Bootstrap null unsetReservedGlobalVariables()
Definition: Bootstrap.php:808
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\getWizard
‪TYPO3 CMS Install Updates UpgradeWizardInterface null getWizard(string $className, string $identifier, $all=false)
Definition: UpgradeWizardListCommand.php:129
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\configure
‪configure()
Definition: UpgradeWizardListCommand.php:66
‪TYPO3\CMS\Install\Updates\ChattyInterface
Definition: ChattyInterface.php:25
‪TYPO3\CMS\Core\Core\Bootstrap\initializeBackendUser
‪static Bootstrap null initializeBackendUser($className=\TYPO3\CMS\Core\Authentication\BackendUserAuthentication::class)
Definition: Bootstrap.php:956
‪TYPO3\CMS\Install\Service\UpgradeWizardsService
Definition: UpgradeWizardsService.php:42
‪TYPO3\CMS\Install\Command
Definition: LanguagePackCommand.php:3
‪TYPO3\CMS\Core\Core\Bootstrap\initializeBackendAuthentication
‪static Bootstrap null initializeBackendAuthentication($proceedIfNoUserIsLoggedIn=false)
Definition: Bootstrap.php:974
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\$input
‪InputInterface $input
Definition: UpgradeWizardListCommand.php:48
‪TYPO3\CMS\Core\Core\Bootstrap\loadTypo3LoadedExtAndExtLocalconf
‪static Bootstrap null loadTypo3LoadedExtAndExtLocalconf($allowCaching=true, FrontendInterface $coreCache=null)
Definition: Bootstrap.php:551
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\execute
‪int execute(InputInterface $input, OutputInterface $output)
Definition: UpgradeWizardListCommand.php:84
‪TYPO3\CMS\Core\Core\Bootstrap\loadExtTables
‪static Bootstrap null loadExtTables(bool $allowCaching=true)
Definition: Bootstrap.php:864
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\bootstrap
‪bootstrap()
Definition: UpgradeWizardListCommand.php:53
‪TYPO3\CMS\Install\Updates\UpgradeWizardInterface
Definition: UpgradeWizardInterface.php:22
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:50
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand
Definition: UpgradeWizardListCommand.php:37
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\$upgradeWizardsService
‪UpgradeWizardsService $upgradeWizardsService
Definition: UpgradeWizardListCommand.php:40
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\$output
‪OutputInterface Symfony Component Console Style StyleInterface $output
Definition: UpgradeWizardListCommand.php:44
‪TYPO3\CMS\Core\Authentication\CommandLineUserAuthentication
Definition: CommandLineUserAuthentication.php:29