‪TYPO3CMS  9.5
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 
17 use Symfony\Component\Console\Application;
18 use Symfony\Component\Console\Command\Command;
20 use TYPO3\CMS\Core\Package\PackageManager;
25 
32 class ‪CoreCommand extends Command
33 {
37  protected ‪$extbaseBootstrap;
38 
42  protected function ‪configure()
43  {
44  $this->setHidden(true);
45  }
46 
55  public function ‪setApplication(Application $application = null)
56  {
57  parent::setApplication($application);
58 
59  // Extbase commands can not be initialized in failsafe mode
60  if (GeneralUtility::makeInstance(PackageManager::class) instanceof ‪FailsafePackageManager) {
61  return;
62  }
63 
64  // Find any registered Extbase commands
65  $this->extbaseBootstrap = GeneralUtility::makeInstance(Bootstrap::class);
66  $this->extbaseBootstrap->initialize([]);
67 
68  $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
69 
71  $commandManager = $objectManager->get(CommandManager::class);
72  $commands = $commandManager->getAvailableCommands();
73  foreach ($commands as $command) {
74  $commandName = $commandManager->getShortestIdentifierForCommand($command);
75  $fullCommandName = $command->getCommandIdentifier();
76  if ($fullCommandName === 'extbase:help:error' || $fullCommandName === 'extbase:help:helpstub') {
77  continue;
78  }
79  if ($commandName === 'help') {
80  $commandName = 'extbase:help';
81  }
82  $extbaseCommand = GeneralUtility::makeInstance(ExtbaseCommand::class, $fullCommandName);
83 
84  if ($commandName !== $fullCommandName) {
85  $extbaseCommand->setAliases([$commandName]);
86  }
87 
88  $extbaseCommand->setExtbaseCommand($command);
89  $this->getApplication()->add($extbaseCommand);
90  }
91  }
92 }
‪TYPO3\CMS\Extbase\Command
Definition: CoreCommand.php:2
‪TYPO3\CMS\Extbase\Command\CoreCommand
Definition: CoreCommand.php:33
‪TYPO3\CMS\Core\Package\FailsafePackageManager
Definition: FailsafePackageManager.php:23
‪TYPO3\CMS\Extbase\Command\CoreCommand\configure
‪configure()
Definition: CoreCommand.php:41
‪TYPO3\CMS\Extbase\Mvc\Cli\CommandManager
Definition: CommandManager.php:23
‪TYPO3\CMS\Extbase\Core\Bootstrap
Definition: Bootstrap.php:31
‪TYPO3\CMS\Extbase\Command\CoreCommand\setApplication
‪setApplication(Application $application=null)
Definition: CoreCommand.php:54
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Extbase\Object\ObjectManager
Definition: ObjectManager.php:25
‪TYPO3\CMS\Extbase\Command\CoreCommand\$extbaseBootstrap
‪Bootstrap $extbaseBootstrap
Definition: CoreCommand.php:36