TYPO3 CMS  TYPO3_8-7
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 
22 
26 class HelpCommand extends \Symfony\Component\Console\Command\HelpCommand
27 {
33  private $command;
34 
38  protected function configure()
39  {
40  parent::configure();
41  $this->setAliases([]);
42  }
43 
49  public function setCommand(Command $command)
50  {
51  $this->command = $command;
52  }
53 
57  protected function execute(InputInterface $input, OutputInterface $output)
58  {
59  if (null === $this->command) {
60  $this->command = $this->getApplication()->find($input->getArgument('command_name'));
61  }
62 
63  // Extbase help was explicitly called
64  if ($input->getArgument('command') === 'extbase:help' || $input->getArgument('command') === 'extbase:help:help') {
65  $_SERVER['argv'][1] = 'extbase:help:help';
66  $bootstrap = GeneralUtility::makeInstance(Bootstrap::class);
67  $bootstrap->run('', []);
68  } elseif ($this->command instanceof ExtbaseCommand) {
69  // An extbase command was originally called, but is now required to show the help information
70  // Ugly hack to modify 'argv' so the help command for a specific command is shown
71  $args = [$_SERVER['argv'][0], 'help'];
72  foreach ($_SERVER['argv'] as $k => $value) {
73  if ($k === 0 || $value === '--help' || $value === '-h') {
74  continue;
75  }
76  $args[] = $value;
77  }
78  $_SERVER['argv'] = $args;
79 
80  // run Extbase bootstrap
81  $bootstrap = GeneralUtility::makeInstance(Bootstrap::class);
82  $bootstrap->run('', []);
83  } else {
84  // Any other symfony command should just show up the regular info
85  parent::execute($input, $output);
86  }
87  }
88 }
execute(InputInterface $input, OutputInterface $output)
Definition: HelpCommand.php:57
static makeInstance($className,... $constructorArguments)