Skip to content

Commit

Permalink
Merge pull request #8 from daniellienert/feature/add-runsingle-command
Browse files Browse the repository at this point in the history
FEATURE: Run a single persisted task ignoring status and schedule
  • Loading branch information
dfeyer authored Aug 1, 2016
2 parents 625dc90 + e18a6a2 commit d18ad07
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 d18ad07

Please sign in to comment.