‪TYPO3CMS  10.4
UpgradeWizardListCommand.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Symfony\Component\Console\Command\Command;
21 use Symfony\Component\Console\Input\InputInterface;
22 use Symfony\Component\Console\Input\InputOption;
23 use Symfony\Component\Console\Output\OutputInterface;
24 use Symfony\Component\Console\Style\SymfonyStyle;
32 
38 class ‪UpgradeWizardListCommand extends Command
39 {
43  private ‪$lateBootService;
44 
49 
53  private ‪$output;
54 
58  private ‪$input;
59 
60  public function ‪__construct(
61  string $name,
64  ) {
65  $this->lateBootService = ‪$lateBootService;
66  $this->upgradeWizardsService = ‪$upgradeWizardsService;
67  parent::__construct($name);
68  }
69 
73  protected function ‪bootstrap(): void
74  {
75  $this->lateBootService->loadExtLocalconfDatabaseAndExtTables();
76  ‪Bootstrap::initializeBackendUser(CommandLineUserAuthentication::class);
78  }
79 
83  protected function ‪configure()
84  {
85  $this->setDescription('List available upgrade wizards.')
86  ->addOption(
87  'all',
88  'a',
89  InputOption::VALUE_NONE,
90  'Include wizards already done.'
91  );
92  }
93 
101  protected function ‪execute(InputInterface ‪$input, OutputInterface ‪$output)
102  {
103  $this->output = new SymfonyStyle(‪$input, ‪$output);
104  $this->input = ‪$input;
105  $this->‪bootstrap();
106 
107  $result = 0;
108  $wizards = [];
109  $all = ‪$input->getOption('all');
110  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'] as $identifier => $wizardToExecute) {
111  $upgradeWizard = $this->‪getWizard($wizardToExecute, $identifier, (bool)$all);
112  if ($upgradeWizard !== null) {
113  $wizardInfo = [
114  'identifier' => $upgradeWizard->getIdentifier(),
115  'title' => $upgradeWizard->getTitle(),
116  'description' => wordwrap($upgradeWizard->getDescription()),
117  ];
118  if ($all === true) {
119  $wizardInfo['status'] = $this->upgradeWizardsService->isWizardDone($identifier) ? 'DONE' : 'AVAILABLE';
120  }
121  $wizards[] = $wizardInfo;
122  }
123  }
124  if (empty($wizards)) {
125  $this->output->success('No wizards available.');
126  } else {
127  if ($all === true) {
128  $this->output->table(['Identifier', 'Title', 'Description', 'Status'], $wizards);
129  } else {
130  $this->output->table(['Identifier', 'Title', 'Description'], $wizards);
131  }
132  }
133  return $result;
134  }
135 
145  protected function ‪getWizard(string $className, string $identifier, $all = false): ?UpgradeWizardInterface
146  {
147  // already done
148  if (!$all && $this->upgradeWizardsService->isWizardDone($identifier)) {
149  return null;
150  }
151 
152  $wizardInstance = GeneralUtility::makeInstance($className);
153  if ($wizardInstance instanceof ChattyInterface) {
154  $wizardInstance->setOutput($this->output);
155  }
156 
157  if (!($wizardInstance instanceof UpgradeWizardInterface)) {
158  return null;
159  }
160 
161  return !$all ? $wizardInstance->updateNecessary() ? $wizardInstance : null : $wizardInstance;
162  }
163 }
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\getWizard
‪TYPO3 CMS Install Updates UpgradeWizardInterface null getWizard(string $className, string $identifier, $all=false)
Definition: UpgradeWizardListCommand.php:141
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\configure
‪configure()
Definition: UpgradeWizardListCommand.php:79
‪TYPO3\CMS\Install\Updates\ChattyInterface
Definition: ChattyInterface.php:26
‪TYPO3\CMS\Core\Core\Bootstrap\initializeBackendAuthentication
‪static initializeBackendAuthentication($proceedIfNoUserIsLoggedIn=false)
Definition: Bootstrap.php:607
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\$lateBootService
‪LateBootService $lateBootService
Definition: UpgradeWizardListCommand.php:42
‪TYPO3\CMS\Install\Service\UpgradeWizardsService
Definition: UpgradeWizardsService.php:43
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\__construct
‪__construct(string $name, LateBootService $lateBootService, UpgradeWizardsService $upgradeWizardsService)
Definition: UpgradeWizardListCommand.php:56
‪TYPO3\CMS\Install\Command
Definition: LanguagePackCommand.php:18
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\$input
‪InputInterface $input
Definition: UpgradeWizardListCommand.php:54
‪TYPO3\CMS\Core\Core\Bootstrap\initializeBackendUser
‪static initializeBackendUser($className=BackendUserAuthentication::class)
Definition: Bootstrap.php:591
‪TYPO3\CMS\Install\Service\LateBootService
Definition: LateBootService.php:34
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\execute
‪int execute(InputInterface $input, OutputInterface $output)
Definition: UpgradeWizardListCommand.php:97
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\bootstrap
‪bootstrap()
Definition: UpgradeWizardListCommand.php:69
‪TYPO3\CMS\Install\Updates\UpgradeWizardInterface
Definition: UpgradeWizardInterface.php:24
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:66
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand
Definition: UpgradeWizardListCommand.php:39
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\$upgradeWizardsService
‪UpgradeWizardsService $upgradeWizardsService
Definition: UpgradeWizardListCommand.php:46
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\$output
‪OutputInterface Symfony Component Console Style StyleInterface $output
Definition: UpgradeWizardListCommand.php:50
‪TYPO3\CMS\Core\Authentication\CommandLineUserAuthentication
Definition: CommandLineUserAuthentication.php:30