‪TYPO3CMS  ‪main
SiteSetsListCommand.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\Helper\Table;
22 use Symfony\Component\Console\Input\InputInterface;
23 use Symfony\Component\Console\Output\OutputInterface;
24 use Symfony\Component\Console\Style\SymfonyStyle;
26 
30 class ‪SiteSetsListCommand extends Command
31 {
32  public function ‪__construct(
33  protected readonly ‪SetCollector $setCollector
34  ) {
35  parent::__construct();
36  }
37 
41  protected function ‪execute(InputInterface $input, OutputInterface ‪$output): int
42  {
43  $io = new SymfonyStyle($input, ‪$output);
44  $sets = $this->setCollector->getSetDefinitions();
45 
46  if ($sets === []) {
47  $io->title('No site sets configured');
48  $io->note('Configure new sites by placing a Configuration/Sets/MySetName/config.yaml in an extension.');
49  return Command::SUCCESS;
50  }
51 
52  $io->title('All configured site sets');
53  $table = new Table(‪$output);
54  $table->setHeaders([
55  'Name',
56  'Label',
57  'Dependencies',
58  ]);
59  foreach ($sets as $set) {
60  $table->addRow(
61  [
62  '<options=bold>' . $set->name . '</>',
63  $set->label,
64  implode(', ', [
65  ...$set->dependencies,
66  ...array_map(static fn(string $d): string => '(' . $d . ')', $set->optionalDependencies),
67  ]),
68  ]
69  );
70  }
71  $table->render();
72  return Command::SUCCESS;
73  }
74 }
‪TYPO3\CMS\Core\Command\SiteSetsListCommand\__construct
‪__construct(protected readonly SetCollector $setCollector)
Definition: SiteSetsListCommand.php:32
‪TYPO3\CMS\Core\Command\SiteSetsListCommand
Definition: SiteSetsListCommand.php:31
‪TYPO3\CMS\Core\Command\SiteSetsListCommand\execute
‪execute(InputInterface $input, OutputInterface $output)
Definition: SiteSetsListCommand.php:41
‪$output
‪$output
Definition: annotationChecker.php:114
‪TYPO3\CMS\Core\Command
Definition: CacheFlushCommand.php:18
‪TYPO3\CMS\Core\Site\Set\SetCollector
Definition: SetCollector.php:24