‪TYPO3CMS  ‪main
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;
31 
37 class ‪UpgradeWizardListCommand extends Command
38 {
40 
44  private ‪$output;
45 
46  public function ‪__construct(string $name, private readonly ‪LateBootService $lateBootService)
47  {
48  parent::__construct($name);
49  }
50 
54  protected function ‪bootstrap(): void
55  {
56  $this->upgradeWizardsService = $this->lateBootService
57  ->loadExtLocalconfDatabaseAndExtTables(false)
58  ->get(UpgradeWizardsService::class);
59  ‪Bootstrap::initializeBackendUser(CommandLineUserAuthentication::class);
61  }
62 
66  protected function ‪configure()
67  {
68  $this->setDescription('List available upgrade wizards.')
69  ->addOption(
70  'all',
71  'a',
72  InputOption::VALUE_NONE,
73  'Include wizards already done.'
74  );
75  }
76 
80  protected function ‪execute(InputInterface $input, OutputInterface ‪$output): int
81  {
82  $this->output = new SymfonyStyle($input, ‪$output);
83  $this->‪bootstrap();
84 
85  $wizards = [];
86  $all = $input->getOption('all');
87  foreach ($this->upgradeWizardsService->getUpgradeWizardIdentifiers() as ‪$identifier) {
88  $upgradeWizard = $this->‪getWizard($identifier, (bool)$all);
89  if ($upgradeWizard !== null) {
90  $wizardInfo = [
91  'identifier' => ‪$identifier,
92  'title' => $upgradeWizard->getTitle(),
93  'description' => wordwrap($upgradeWizard->getDescription()),
94  ];
95  if ($all === true) {
96  $wizardInfo['status'] = $this->upgradeWizardsService->isWizardDone(‪$identifier) ? 'DONE' : 'AVAILABLE';
97  }
98  $wizards[] = $wizardInfo;
99  }
100  }
101  if (empty($wizards)) {
102  $this->output->success('No wizards available.');
103  } elseif ($all === true) {
104  $this->output->table(['Identifier', 'Title', 'Description', 'Status'], $wizards);
105  } else {
106  $this->output->table(['Identifier', 'Title', 'Description'], $wizards);
107  }
108  return Command::SUCCESS;
109  }
110 
115  protected function ‪getWizard(string ‪$identifier, bool $all = false): ?UpgradeWizardInterface
116  {
117  // already done
118  if (!$all && $this->upgradeWizardsService->isWizardDone(‪$identifier)) {
119  return null;
120  }
121 
122  $wizard = $this->upgradeWizardsService->getUpgradeWizard(‪$identifier);
123  if ($wizard === null) {
124  return null;
125  }
126 
127  if ($wizard instanceof ChattyInterface) {
128  $wizard->setOutput($this->output);
129  }
130 
131  return !$all ? $wizard->updateNecessary() ? $wizard : null : $wizard;
132  }
133 }
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\execute
‪execute(InputInterface $input, OutputInterface $output)
Definition: UpgradeWizardListCommand.php:79
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\getWizard
‪getWizard(string $identifier, bool $all=false)
Definition: UpgradeWizardListCommand.php:114
‪TYPO3\CMS\Install\Updates\UpgradeWizardInterface\updateNecessary
‪updateNecessary()
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\configure
‪configure()
Definition: UpgradeWizardListCommand.php:65
‪TYPO3\CMS\Install\Updates\ChattyInterface
Definition: ChattyInterface.php:26
‪TYPO3\CMS\Install\Service\UpgradeWizardsService
Definition: UpgradeWizardsService.php:40
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\__construct
‪__construct(string $name, private readonly LateBootService $lateBootService)
Definition: UpgradeWizardListCommand.php:45
‪TYPO3\CMS\Install\Command
Definition: LanguagePackCommand.php:18
‪TYPO3\CMS\Core\Core\Bootstrap\initializeBackendUser
‪static initializeBackendUser($className=BackendUserAuthentication::class, ServerRequestInterface $request=null)
Definition: Bootstrap.php:513
‪TYPO3\CMS\Install\Service\LateBootService
Definition: LateBootService.php:27
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\bootstrap
‪bootstrap()
Definition: UpgradeWizardListCommand.php:53
‪TYPO3\CMS\Install\Updates\UpgradeWizardInterface
Definition: UpgradeWizardInterface.php:24
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:63
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand
Definition: UpgradeWizardListCommand.php:38
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\$upgradeWizardsService
‪UpgradeWizardsService $upgradeWizardsService
Definition: UpgradeWizardListCommand.php:39
‪TYPO3\CMS\Install\Command\UpgradeWizardListCommand\$output
‪OutputInterface Symfony Component Console Style StyleInterface $output
Definition: UpgradeWizardListCommand.php:43
‪TYPO3\CMS\Core\Core\Bootstrap\initializeBackendAuthentication
‪static initializeBackendAuthentication()
Definition: Bootstrap.php:528
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37
‪TYPO3\CMS\Core\Authentication\CommandLineUserAuthentication
Definition: CommandLineUserAuthentication.php:31