‪TYPO3CMS  9.5
CommandApplication.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 use Symfony\Component\Console\Input\ArgvInput;
24 
31 {
34  public function ‪__construct()
35  {
36  $this->‪checkEnvironmentOrDie();
37  }
38 
44  public function ‪run(callable $execute = null)
45  {
46  $this->‪initializeContext();
47  $handler = GeneralUtility::makeInstance(CommandRequestHandler::class);
48  $handler->handleRequest(new ArgvInput());
49 
50  if ($execute !== null) {
51  call_user_func($execute);
52  }
53  }
54 
58  protected function ‪checkEnvironmentOrDie()
59  {
60  if (PHP_SAPI !== 'cli') {
61  die('Not called from a command line interface (e.g. a shell or scheduler).' . LF);
62  }
63  }
64 
69  protected function ‪initializeContext()
70  {
71  GeneralUtility::makeInstance(Context::class, [
72  'date' => new ‪DateTimeAspect(new \DateTimeImmutable('@' . ‪$GLOBALS['EXEC_TIME'])),
73  'visibility' => new ‪VisibilityAspect(true, true),
74  'workspace' => new ‪WorkspaceAspect(0),
75  'backend.user' => new ‪UserAspect(null),
76  ]);
77  }
78 }
‪TYPO3\CMS\Core\Context\VisibilityAspect
Definition: VisibilityAspect.php:29
‪TYPO3\CMS\Core\Context\WorkspaceAspect
Definition: WorkspaceAspect.php:29
‪TYPO3\CMS\Core\Console\CommandApplication\__construct
‪__construct()
Definition: CommandApplication.php:34
‪TYPO3\CMS\Core\Console
Definition: CommandApplication.php:2
‪TYPO3\CMS\Core\Context\Context
Definition: Context.php:49
‪TYPO3\CMS\Core\Console\CommandApplication
Definition: CommandApplication.php:31
‪TYPO3\CMS\Core\Console\CommandApplication\run
‪run(callable $execute=null)
Definition: CommandApplication.php:44
‪TYPO3\CMS\Core\Core\ApplicationInterface
Definition: ApplicationInterface.php:23
‪TYPO3\CMS\Core\Console\CommandApplication\checkEnvironmentOrDie
‪checkEnvironmentOrDie()
Definition: CommandApplication.php:58
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Console\CommandApplication\initializeContext
‪initializeContext()
Definition: CommandApplication.php:69
‪TYPO3\CMS\Core\Context\DateTimeAspect
Definition: DateTimeAspect.php:33
‪TYPO3\CMS\Core\Context\UserAspect
Definition: UserAspect.php:36