getId()); $report = new Report(\common_report_Report::TYPE_INFO, __('Running task %s at %s', $task->getId(), microtime(true))); /** @var TaskQueue $queue */ $queue = $this->getServiceLocator()->get(Queue::SERVICE_ID); $queue->updateTaskStatus($task->getId(), Task::STATUS_RUNNING); try { $actionService = $this->getServiceLocator()->get(ActionService::SERVICE_ID); $invocable = $task->getInvocable(); if (is_string($invocable)) { $invocable = $actionService->resolve($task->getInvocable()); } elseif ($invocable instanceof ServiceLocatorAwareInterface) { $invocable->setServiceLocator($this->getServiceLocator()); } $subReport = call_user_func($invocable, $task->getParameters()); $report->add($subReport); $report->setMessage($report->getMessage() . '; ' . __('Finished at %s', microtime(true))); } catch (\Exception $e) { $message = __('Failed at %s; Error message: %s', microtime(true), $e->getMessage()); \common_Logger::e($message); $report->setType(Report::TYPE_ERROR); $report->setMessage($report->getMessage() . '; ' . $message); } $queue->updateTaskStatus($task->getId(), Task::STATUS_FINISHED); $queue->updateTaskReport($task->getId(), $report); return $report; } }