‪TYPO3CMS  10.4
CommandRequestHandler.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 Symfony\Component\Console\Application;
21 use Symfony\Component\Console\Command\Command;
22 use Symfony\Component\Console\Input\InputInterface;
23 use Symfony\Component\Console\Output\ConsoleOutput;
30 
37 {
42  protected ‪$application;
43 
47  public function ‪__construct()
48  {
49  trigger_error('CommandRequestHandler will be removed in TYPO3 v11.0, as CLI is executed inside the CommandApplication directly.', E_USER_DEPRECATED);
50  $this->application = new Application('TYPO3 CMS', sprintf(
51  '%s (Application Context: <comment>%s</comment>)',
52  (new ‪Typo3Version())->getVersion(),
54  ));
55  }
56 
62  public function ‪handleRequest(InputInterface $input)
63  {
64  ‪$output = new ConsoleOutput();
65 
67  // create the BE_USER object (not logged in yet)
68  ‪Bootstrap::initializeBackendUser(CommandLineUserAuthentication::class);
70  // Make sure output is not buffered, so command-line output and interaction can take place
71  ob_clean();
72 
74 
75  $exitCode = $this->application->run($input, ‪$output);
76  exit($exitCode);
77  }
78 
85  public function ‪canHandleRequest(InputInterface $input): bool
86  {
87  return true;
88  }
89 
95  public function ‪getPriority(): int
96  {
97  return 50;
98  }
99 
104  protected function ‪populateAvailableCommands()
105  {
106  $commands = GeneralUtility::makeInstance(CommandRegistry::class);
107 
108  foreach ($commands as $commandName => $command) {
110  $this->application->add($command);
111  }
112  }
113 }
‪TYPO3\CMS\Core\Console\CommandRequestHandler\getPriority
‪int getPriority()
Definition: CommandRequestHandler.php:94
‪TYPO3\CMS\Core\Console\CommandRequestHandler
Definition: CommandRequestHandler.php:37
‪TYPO3\CMS\Core\Information\Typo3Version
Definition: Typo3Version.php:21
‪TYPO3\CMS\Core\Console\CommandRequestHandler\handleRequest
‪handleRequest(InputInterface $input)
Definition: CommandRequestHandler.php:61
‪TYPO3\CMS\Core\Console\CommandRequestHandler\__construct
‪__construct()
Definition: CommandRequestHandler.php:46
‪TYPO3\CMS\Core\Console
Definition: CommandApplication.php:16
‪TYPO3\CMS\Core\Core\Environment\getContext
‪static ApplicationContext getContext()
Definition: Environment.php:133
‪TYPO3\CMS\Core\Localization\LanguageService\createFromUserPreferences
‪static createFromUserPreferences(?AbstractUserAuthentication $user)
Definition: LanguageService.php:435
‪TYPO3\CMS\Core\Console\CommandRequestHandler\canHandleRequest
‪bool canHandleRequest(InputInterface $input)
Definition: CommandRequestHandler.php:84
‪TYPO3\CMS\Core\Console\RequestHandlerInterface
Definition: RequestHandlerInterface.php:29
‪TYPO3\CMS\Core\Core\Bootstrap\initializeBackendUser
‪static initializeBackendUser($className=BackendUserAuthentication::class)
Definition: Bootstrap.php:591
‪TYPO3\CMS\Core\Console\CommandRequestHandler\$application
‪Application $application
Definition: CommandRequestHandler.php:41
‪$output
‪$output
Definition: annotationChecker.php:119
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:40
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:66
‪TYPO3\CMS\Core\Console\CommandRequestHandler\populateAvailableCommands
‪populateAvailableCommands()
Definition: CommandRequestHandler.php:103
‪TYPO3\CMS\Core\Core\Bootstrap\loadExtTables
‪static loadExtTables(bool $allowCaching=true)
Definition: Bootstrap.php:546
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Authentication\CommandLineUserAuthentication
Definition: CommandLineUserAuthentication.php:30