diff --git a/packages/ep_products/Classes/Command/SchedulerTasksCommand.php b/packages/ep_products/Classes/Command/SchedulerTasksCommand.php deleted file mode 100644 index 9d28ca2..0000000 --- a/packages/ep_products/Classes/Command/SchedulerTasksCommand.php +++ /dev/null @@ -1,82 +0,0 @@ - 'ep:import-dates', 'cron' => '*/15 6-20 * * *', 'multiple' => true, 'group' => 1, 'description' => 'Reisedaten aus MyE&P importieren'], - ['command' => 'ep:import-snowreport', 'cron' => '0 6 * * *', 'multiple' => false, 'group' => 1, 'description' => 'Schneehöhen importieren'], - ['command' => 'ep:groups-swiss', 'cron' => '0 14 * * *', 'multiple' => false, 'group' => 2, 'description' => 'Belegung der Gruppenhäuser nach groups.swiss exportieren'], - ]; - - public function __construct( - private readonly SchedulerTaskRepository $taskRepository, - private readonly ConnectionPool $connectionPool, - ) { - parent::__construct(); - } - - protected function configure(): void - { - $this->addOption('dry-run', null, InputOption::VALUE_NONE, 'Only show what would change'); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - $dryRun = (bool)$input->getOption('dry-run'); - - $existing = []; - foreach ($this->connectionPool->getConnectionForTable('tx_scheduler_task')->select(['uid', 'serialized_task_object'], 'tx_scheduler_task', ['deleted' => 0])->fetchAllAssociative() as $row) { - if (in_array((int)$row['uid'], self::OLD_TASKS, true)) { - $output->writeln(sprintf('Delete TYPO3 10 task %d', $row['uid'])); - if (!$dryRun) { - $this->taskRepository->remove((int)$row['uid']); - } - } elseif (preg_match('/s:20:"\0\*\0commandIdentifier";s:\d+:"([^"]+)"/', (string)$row['serialized_task_object'], $matches)) { - $existing[$matches[1]] = (int)$row['uid']; - } - } - - foreach (self::NEW_TASKS as $config) { - if (isset($existing[$config['command']])) { - $output->writeln(sprintf('Task for %s exists (%d)', $config['command'], $existing[$config['command']])); - continue; - } - $output->writeln(sprintf('Add task for %s (%s)', $config['command'], $config['cron'])); - if ($dryRun) { - continue; - } - $task = GeneralUtility::makeInstance(ExecuteSchedulableCommandTask::class); - $task->setCommandIdentifier($config['command']); - $task->setDescription($config['description']); - $task->setTaskGroup($config['group']); - $task->registerRecurringExecution($GLOBALS['EXEC_TIME'] - 1, 0, 0, $config['multiple'], $config['cron']); - $this->taskRepository->add($task); - } - - return Command::SUCCESS; - } -}