‪TYPO3CMS  ‪main
ListCommand.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 Psr\Container\ContainerInterface;
21 use Symfony\Component\Console\Command\Command;
22 use Symfony\Component\Console\Command\ListCommand as SymfonyListCommand;
23 use Symfony\Component\Console\Helper\DescriptorHelper;
24 use Symfony\Component\Console\Input\InputInterface;
25 use Symfony\Component\Console\Output\OutputInterface;
29 
33 class ‪ListCommand extends SymfonyListCommand
34 {
35  public function ‪__construct(
36  protected readonly ContainerInterface $failsafeContainer,
37  protected readonly ‪BootService $bootService,
38  ) {
39  parent::__construct();
40  }
41 
45  protected function ‪execute(InputInterface $input, OutputInterface ‪$output): int
46  {
47  $degraded = false;
48  try {
49  $container = $this->bootService->getContainer();
50  } catch (\Throwable $e) {
51  $container = $this->failsafeContainer;
52  $degraded = true;
53  }
54 
55  $commandRegistry = $container->get(CommandRegistry::class);
56 
57  $helper = new DescriptorHelper();
58  $helper->register('txt', new ‪TextDescriptor($commandRegistry, $degraded));
59  $helper->describe(‪$output, $this->getApplication(), [
60  'format' => $input->getOption('format'),
61  'raw_text' => $input->getOption('raw'),
62  'namespace' => $input->getArgument('namespace'),
63  ]);
64 
65  return Command::SUCCESS;
66  }
67 }
‪TYPO3\CMS\Core\Command\ListCommand
Definition: ListCommand.php:34
‪TYPO3\CMS\Core\Command\ListCommand\execute
‪execute(InputInterface $input, OutputInterface $output)
Definition: ListCommand.php:45
‪TYPO3\CMS\Core\Core\BootService
Definition: BootService.php:35
‪TYPO3\CMS\Core\Console\CommandRegistry
Definition: CommandRegistry.php:31
‪TYPO3\CMS\Core\Command\ListCommand\__construct
‪__construct(protected readonly ContainerInterface $failsafeContainer, protected readonly BootService $bootService,)
Definition: ListCommand.php:35
‪$output
‪$output
Definition: annotationChecker.php:114
‪TYPO3\CMS\Core\Command
Definition: CacheFlushCommand.php:18
‪TYPO3\CMS\Core\Command\Descriptor\TextDescriptor
Definition: TextDescriptor.php:33