‪TYPO3CMS  9.5
HelpCommand.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
17 use Symfony\Component\Console\Command\Command;
18 use Symfony\Component\Console\Input\InputInterface;
19 use Symfony\Component\Console\Output\OutputInterface;
22 
27 class ‪HelpCommand extends \Symfony\Component\Console\Command\HelpCommand
28 {
34  private ‪$command;
35 
39  protected function ‪configure()
40  {
41  parent::configure();
42  $this->setAliases([]);
43  }
44 
48  protected function ‪execute(InputInterface $input, OutputInterface ‪$output)
49  {
50  if (null === $this->command) {
51  $this->command = $this->getApplication()->find($input->getArgument('command_name'));
52  }
53 
54  // Extbase help was explicitly called
55  if ($input->getArgument('command') === 'extbase:help' || $input->getArgument('command') === 'extbase:help:help') {
56  $_SERVER['argv'][1] = 'extbase:help:help';
57  $bootstrap = GeneralUtility::makeInstance(Bootstrap::class);
58  $bootstrap->run('', []);
59  } elseif ($this->command instanceof ‪ExtbaseCommand) {
60  // An extbase command was originally called, but is now required to show the help information
61  // Ugly hack to modify 'argv' so the help command for a specific command is shown
62  ‪$args = [$_SERVER['argv'][0], 'help'];
63  foreach ($_SERVER['argv'] as $k => $value) {
64  if ($k === 0 || $value === '--help' || $value === '-h') {
65  continue;
66  }
67  ‪$args[] = $value;
68  }
69  $_SERVER['argv'] = ‪$args;
70 
71  // run Extbase bootstrap
72  $bootstrap = GeneralUtility::makeInstance(Bootstrap::class);
73  $bootstrap->run('', []);
74  } else {
75  // Any other symfony command should just show up the regular info
76  parent::execute($input, ‪$output);
77  }
78  }
79 }
‪TYPO3\CMS\Extbase\Command
Definition: CoreCommand.php:2
‪$args
‪$args
Definition: checkIntegrityCsvFixtures.php:230
‪TYPO3\CMS\Extbase\Command\HelpCommand
Definition: HelpCommand.php:28
‪TYPO3\CMS\Extbase\Command\HelpCommand\execute
‪execute(InputInterface $input, OutputInterface $output)
Definition: HelpCommand.php:47
‪TYPO3\CMS\Extbase\Command\HelpCommand\$command
‪Command $command
Definition: HelpCommand.php:33
‪$output
‪$output
Definition: annotationChecker.php:113
‪TYPO3\CMS\Extbase\Core\Bootstrap
Definition: Bootstrap.php:31
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Extbase\Command\ExtbaseCommand
Definition: ExtbaseCommand.php:29
‪TYPO3\CMS\Extbase\Command\HelpCommand\configure
‪configure()
Definition: HelpCommand.php:38