*/ class RunTask extends ScriptAction { /** * @return Report * @throws \Exception */ protected function run(): Report { /** @var QueueDispatcherInterface $queueService */ $queueService = $this->getServiceLocator()->get(QueueDispatcherInterface::SERVICE_ID); /** @var TaskLogInterface $taskLog */ $taskLog = $this->getServiceLocator()->get(TaskLogInterface::SERVICE_ID); /** @var TaskSerializerService $taskSerializer */ $taskSerializer = $this->getServiceLocator()->get(TaskSerializerService::SERVICE_ID); $taskJSON = $this->getOption('task'); $task = $taskSerializer->deserialize(base64_decode($taskJSON)); $runner = new OneTimeTask($queueService, $taskLog); $runner->setTask($task); $status = $runner->run(); return Report::createInfo($status); } protected function provideOptions(): array { return [ 'task' => [ 'prefix' => 't', 'longPrefix' => 'task', 'cast' => 'string', 'required' => true, 'description' => 'Task json-base64encoded to run.' ] ]; } protected function provideDescription(): string { return 'Run a task'; } }