Skip to content

Commit

Permalink
FEATURE: Run a single persisted task ignoring status and schedule
Browse files Browse the repository at this point in the history
This feature adds a commad to execute a single task while
ignoring status and schedule.
  • Loading branch information
daniellienert committed Aug 1, 2016
1 parent 625dc90 commit e18a6a2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Classes/Ttree/Scheduler/Command/TaskCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit e18a6a2

Please sign in to comment.