TYPO3 CMS  TYPO3_8-7
CoreCommand.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 
23 
29 class CoreCommand extends Command
30 {
34  protected $extbaseBootstrap;
35 
39  protected function configure()
40  {
41  if (method_exists($this, 'setHidden')) {
42  $this->setHidden(true);
43  }
44  }
45 
54  public function setApplication(Application $application = null)
55  {
56  parent::setApplication($application);
57 
58  // Find any registered Extbase commands
59  $this->extbaseBootstrap = GeneralUtility::makeInstance(Bootstrap::class);
60  $this->extbaseBootstrap->initialize([]);
61 
62  $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
63 
65  $commandManager = $objectManager->get(CommandManager::class);
66  $commands = $commandManager->getAvailableCommands();
67  foreach ($commands as $command) {
68  $commandName = $commandManager->getShortestIdentifierForCommand($command);
69  $fullCommandName = $command->getCommandIdentifier();
70  if ($fullCommandName === 'extbase:help:error' || $fullCommandName === 'extbase:help:helpstub') {
71  continue;
72  }
73  if ($commandName === 'help') {
74  $commandName = 'extbase:help';
75  }
76  $extbaseCommand = GeneralUtility::makeInstance(ExtbaseCommand::class, $fullCommandName);
77 
78  if ($commandName !== $fullCommandName) {
79  $extbaseCommand->setAliases([$commandName]);
80  }
81 
82  $extbaseCommand->setExtbaseCommand($command);
83  $this->getApplication()->add($extbaseCommand);
84  }
85  }
86 }
static makeInstance($className,... $constructorArguments)