From e18a6a2c98b08ca1d554eab2e4ac08f7d8a75cc0 Mon Sep 17 00:00:00 2001 From: Daniel Lienert Date: Mon, 1 Aug 2016 13:16:05 +0200 Subject: [PATCH] FEATURE: Run a single persisted task ignoring status and schedule This feature adds a commad to execute a single task while ignoring status and schedule. --- .../Command/TaskCommandController.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Classes/Ttree/Scheduler/Command/TaskCommandController.php b/Classes/Ttree/Scheduler/Command/TaskCommandController.php index 972e040..0192775 100644 --- a/Classes/Ttree/Scheduler/Command/TaskCommandController.php +++ b/Classes/Ttree/Scheduler/Command/TaskCommandController.php @@ -90,6 +90,24 @@ public function removeCommand(Task $task) $this->taskService->remove($task); } + /** + * Run a single persisted task ignoring status and schedule. + * + * @param Task $task + */ + public function runSingleCommand(Task $task) { + $taskDescriptor = $this->taskService->getTaskDescriptor(TaskInterface::TYPE_PERSISTED, $task); + $arguments = [$task->getImplementation(), $taskDescriptor['identifier'] ?: $taskDescriptor['type']]; + + try { + $taskDescriptor['object']->execute($this->objectManager); + $this->taskService->update($task, $taskDescriptor['type']); + $this->tellStatus('[Success] Run "%s" (%s)', $arguments); + } catch (\Exception $exception) { + $this->tellStatus('[Error] Task "%s" (%s) throw an exception, check your log', $arguments); + } + } + /** * Enable the given persistent class *