‪TYPO3CMS  9.5
TaskExecutor.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 
25 {
29  protected ‪$request;
30 
34  protected ‪$response;
35 
39  protected ‪$dispatcher;
40 
44  protected ‪$objectManager;
45 
49  protected ‪$commandManager;
50 
54  protected ‪$configurationManager;
55 
59  public function ‪injectObjectManager(\‪TYPO3\CMS\‪Extbase\Object\ObjectManagerInterface ‪$objectManager)
60  {
61  $this->objectManager = ‪$objectManager;
62  }
63 
68  {
69  $this->commandManager = ‪$commandManager;
70  }
71 
75  public function ‪injectConfigurationManager(\‪TYPO3\CMS\‪Extbase\Configuration\ConfigurationManagerInterface ‪$configurationManager)
76  {
77  $this->configurationManager = ‪$configurationManager;
78  }
79 
83  public function ‪initializeObject()
84  {
85  $this->dispatcher = $this->objectManager->get(\‪TYPO3\CMS\‪Extbase\Mvc\Dispatcher::class);
86  }
87 
93  protected function ‪initialize(array $configuration)
94  {
95  // initialize unconsumed Request and Response
96  $this->request = $this->objectManager->get(\‪TYPO3\CMS\‪Extbase\Mvc\Cli\Request::class);
97  $this->response = $this->objectManager->get(\‪TYPO3\CMS\‪Extbase\Mvc\Cli\Response::class);
98  // initialize configuration
99  $this->configurationManager->setContentObject(\‪TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\‪TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class));
100  $this->configurationManager->setConfiguration($configuration);
101  // configure object container
102  $frameworkConfiguration = $this->configurationManager->getConfiguration(\‪TYPO3\CMS\‪Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
103  if (isset($frameworkConfiguration['objects'])) {
104  $objectContainer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\‪TYPO3\CMS\‪Extbase\Object\Container\Container::class);
105  foreach ($frameworkConfiguration['objects'] as $classNameWithDot => $classConfiguration) {
106  if (isset($classConfiguration['className'])) {
107  $originalClassName = rtrim($classNameWithDot, '.');
108  $objectContainer->registerImplementation($originalClassName, $classConfiguration['className']);
109  }
110  }
111  }
112  }
113 
122  public function ‪execute(\‪TYPO3\CMS\‪Extbase\Scheduler\‪Task $task)
123  {
124  $commandIdentifier = $task->getCommandIdentifier();
125  list($extensionKey, $controllerName, $commandName) = explode(':', $commandIdentifier);
126  $extensionName = \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($extensionKey);
127  $this->‪initialize(['extensionName' => $extensionName]);
128  // execute command
129  $command = $this->commandManager->getCommandByIdentifier($commandIdentifier);
130  $this->request->setControllerObjectName($command->getControllerClassName());
131  $this->request->setControllerCommandName($command->getControllerCommandName());
132  $this->request->setArguments($task->getArguments());
133  $this->dispatcher->dispatch($this->request, $this->response);
134  $this->‪shutdown();
135  }
136 
140  protected function ‪shutdown()
141  {
142  $persistenceManager = $this->objectManager->get(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\PersistenceManager::class);
143  $persistenceManager->persistAll();
144  }
145 }
‪TYPO3\CMS\Extbase\Scheduler\TaskExecutor\injectConfigurationManager
‪injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager)
Definition: TaskExecutor.php:69
‪TYPO3\CMS\Extbase\Scheduler
Definition: FieldProvider.php:2
‪TYPO3\CMS\Extbase\Scheduler\TaskExecutor\$request
‪TYPO3 CMS Extbase Mvc Cli Request $request
Definition: TaskExecutor.php:28
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:4
‪TYPO3\CMS\Extbase\Scheduler\TaskExecutor
Definition: TaskExecutor.php:25
‪TYPO3
‪TYPO3\CMS\Extbase\Scheduler\TaskExecutor\initialize
‪initialize(array $configuration)
Definition: TaskExecutor.php:87
‪TYPO3\CMS\Extbase\Scheduler\Task
Definition: Task.php:28
‪TYPO3\CMS\Extbase\Scheduler\TaskExecutor\$objectManager
‪TYPO3 CMS Extbase Object ObjectManagerInterface $objectManager
Definition: TaskExecutor.php:40
‪TYPO3\CMS\Extbase\Scheduler\TaskExecutor\initializeObject
‪initializeObject()
Definition: TaskExecutor.php:77
‪TYPO3\CMS\Extbase\Scheduler\TaskExecutor\execute
‪execute(\TYPO3\CMS\Extbase\Scheduler\Task $task)
Definition: TaskExecutor.php:116
‪TYPO3\CMS\Extbase\Mvc\Cli\CommandManager
Definition: CommandManager.php:23
‪TYPO3\CMS\Extbase\Scheduler\TaskExecutor\shutdown
‪shutdown()
Definition: TaskExecutor.php:134
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:22
‪TYPO3\CMS\Extbase\Scheduler\TaskExecutor\injectCommandManager
‪injectCommandManager(\TYPO3\CMS\Extbase\Mvc\Cli\CommandManager $commandManager)
Definition: TaskExecutor.php:61
‪TYPO3\CMS\Extbase\Scheduler\TaskExecutor\$response
‪TYPO3 CMS Extbase Mvc Cli Response $response
Definition: TaskExecutor.php:32
‪TYPO3\CMS\Extbase\Scheduler\TaskExecutor\$commandManager
‪TYPO3 CMS Extbase Mvc Cli CommandManager $commandManager
Definition: TaskExecutor.php:44
‪TYPO3\CMS\Extbase\Scheduler\TaskExecutor\injectObjectManager
‪injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
Definition: TaskExecutor.php:53
‪TYPO3\CMS\Extbase\Scheduler\TaskExecutor\$configurationManager
‪TYPO3 CMS Extbase Configuration ConfigurationManagerInterface $configurationManager
Definition: TaskExecutor.php:48
‪TYPO3\CMS\Extbase\Scheduler\TaskExecutor\$dispatcher
‪TYPO3 CMS Extbase Mvc Dispatcher $dispatcher
Definition: TaskExecutor.php:36