‪TYPO3CMS  ‪main
AvailableSchedulerTasksController.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 Psr\Http\Message\ResponseInterface;
21 use Psr\Http\Message\ServerRequestInterface;
22 use Symfony\Component\Console\Command\Command;
23 use ‪TYPO3\CMS\Backend\Attribute\AsController as BackendController;
30 
36 #[BackendController]
38 {
39  public function ‪__construct(
40  private readonly ‪ModuleTemplateFactory $moduleTemplateFactory,
41  private readonly ‪CommandRegistry $commandRegistry,
42  private readonly ‪TaskService $taskService,
43  ) {}
44 
45  public function ‪handle(ServerRequestInterface $request): ResponseInterface
46  {
47  $languageService = $this->‪getLanguageService();
48 
49  $tasks = $this->taskService->getAvailableTaskTypes();
50  $commands = $this->‪getRegisteredCommands($tasks);
51 
52  $view = $this->moduleTemplateFactory->create($request);
53  $view->setTitle(
54  $languageService->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang_mod.xlf:mlang_tabs_tab'),
55  $languageService->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:function.info')
56  );
57  $view->makeDocHeaderModuleMenu();
58  $this->‪addDocHeaderShortcutButton($view, $languageService->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:function.info'));
59  $view->assignMultiple([
60  'dateFormat' => [
61  'day' => ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] ?? 'd-m-y',
62  'time' => ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] ?? 'H:i',
63  ],
64  'registeredClasses' => $tasks,
65  'commands' => $commands,
66  ]);
67  return $view->renderResponse('InfoScreen');
68  }
69 
70  private function ‪addDocHeaderShortcutButton(‪ModuleTemplate $moduleTemplate, string $name): void
71  {
72  $buttonBar = $moduleTemplate->‪getDocHeaderComponent()->getButtonBar();
73  $shortcutButton = $buttonBar->makeShortcutButton()
74  ->setRouteIdentifier('scheduler_availabletasks')
75  ->setDisplayName($name);
76  $buttonBar->addButton($shortcutButton);
77  }
78 
84  private function ‪getRegisteredCommands(array $tasks): array
85  {
86  $commands = [];
87  if (array_key_exists(ExecuteSchedulableCommandTask::class, $tasks)) {
88  foreach ($this->commandRegistry->getSchedulableCommands() as $commandIdentifier => $command) {
89  $commands[$commandIdentifier] = $command;
90  }
91  ksort($commands);
92  }
93  return $commands;
94  }
95 
97  {
98  return ‪$GLOBALS['LANG'];
99  }
100 }
‪TYPO3\CMS\Backend\Template\ModuleTemplateFactory
Definition: ModuleTemplateFactory.php:33
‪TYPO3\CMS\Scheduler\Controller\AvailableSchedulerTasksController\addDocHeaderShortcutButton
‪addDocHeaderShortcutButton(ModuleTemplate $moduleTemplate, string $name)
Definition: AvailableSchedulerTasksController.php:70
‪TYPO3\CMS\Scheduler\Controller
Definition: AvailableSchedulerTasksController.php:18
‪TYPO3\CMS\Scheduler\Controller\AvailableSchedulerTasksController\handle
‪handle(ServerRequestInterface $request)
Definition: AvailableSchedulerTasksController.php:45
‪TYPO3\CMS\Scheduler\Task\ExecuteSchedulableCommandTask
Definition: ExecuteSchedulableCommandTask.php:32
‪TYPO3\CMS\Scheduler\Controller\AvailableSchedulerTasksController\__construct
‪__construct(private readonly ModuleTemplateFactory $moduleTemplateFactory, private readonly CommandRegistry $commandRegistry, private readonly TaskService $taskService,)
Definition: AvailableSchedulerTasksController.php:39
‪TYPO3\CMS\Backend\Template\ModuleTemplate
Definition: ModuleTemplate.php:46
‪TYPO3\CMS\Core\Console\CommandRegistry
Definition: CommandRegistry.php:31
‪TYPO3\CMS\Scheduler\Controller\AvailableSchedulerTasksController\getRegisteredCommands
‪Command[] getRegisteredCommands(array $tasks)
Definition: AvailableSchedulerTasksController.php:84
‪TYPO3\CMS\Scheduler\Controller\AvailableSchedulerTasksController
Definition: AvailableSchedulerTasksController.php:38
‪TYPO3\CMS\Backend\Template\ModuleTemplate\getDocHeaderComponent
‪getDocHeaderComponent()
Definition: ModuleTemplate.php:181
‪TYPO3\CMS\Scheduler\Controller\AvailableSchedulerTasksController\getLanguageService
‪getLanguageService()
Definition: AvailableSchedulerTasksController.php:96
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\Attribute\AsController
Definition: AsController.php:25
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Scheduler\Service\TaskService
Definition: TaskService.php:27