/** * Generates a symfony2 console command to execute from the task * * @param WorkPackage $work * @throws TaskCommandGeneratorException * @return string */ public function generate(WorkPackage $work) { $description = $work->getTaskDescription(); $command = $description->getCommand(); if (!$this->isValidCommand($command)) { throw new TaskCommandGeneratorException("This command is not usable '{$command}' is not valid"); } $cmd = escapeshellarg($command); $cmd .= $this->generateArguments($description); $cmd .= $this->generateOptions($description); return $cmd; }
/** * Updates the task status * * @param WorkPackage $task * @param string $status * @return void * @throws TaskQueueServiceException */ private function updateTaskStatus(WorkPackage $task, $status) { if ($this->databaseDisabled) { return; } $taskEntity = $task->getTaskEntity(); if ($taskEntity instanceof Task) { $taskEntity->setStatus($status); //make sure it is stored... $this->entityManager->flush($taskEntity); } else { throw new TaskQueueServiceException("Entity is not of type Task"); } }