src/Controller/TaskRunnerController.php
public function addTaskAction(Request $request)
    {
        $metaData = null;
        $content  = $request->getContent();
        if (empty($content)) {
            throw new NotAcceptableHttpException('Invalid payload');
        }
        $metaData = new JsonArray($content);
        if (!$metaData->has('type')) {
            throw new NotAcceptableHttpException('Invalid payload');
        }

        try {
            $taskId = $this->getTensideTasks()->queue($metaData->get('type'), $metaData);
        } catch (\InvalidArgumentException $exception) {
            throw new NotAcceptableHttpException($exception->getMessage());
        }

        return $this->createJsonResponse(
            [$this->convertTaskToArray($this->getTensideTasks()->getTask($taskId))],
            false,
            'OK',
            JsonResponse::HTTP_CREATED
        );
    }
public function addTaskAction(Request $request)
    {
        $metaData = null;
        $content  = $request->getContent();
        if (empty($content)) {
            throw new NotAcceptableHttpException('Invalid payload');
        }
        $metaData = new JsonArray($content);
        if (!$metaData->has('type')) {
            throw new NotAcceptableHttpException('Invalid payload');
        }

        try {
            $taskId = $this->getTensideTasks()->queue($metaData->get('type'), $metaData);
        } catch (\InvalidArgumentException $exception) {
            throw new NotAcceptableHttpException($exception->getMessage());
        }

        return $this->createJsonResponse(
            [$this->convertTaskToArray($this->getTensideTasks()->getTask($taskId))],
            false,
            'OK',
            JsonResponse::HTTP_CREATED
        );
    }
public function addTaskAction ( Request $ request ) { $ metaData = null ; $ content = $ request -> getContent ( ) ; if ( empty ( $ content ) ) { throw new NotAcceptableHttpException ( 'Invalid payload' ) ; } $ metaData = new JsonArray ( $ content ) ; if ( ! $ metaData -> has ( 'type' ) ) { throw new NotAcceptableHttpException ( 'Invalid payload' ) ; } try { $ taskId = $ this -> getTensideTasks ( ) -> queue ( $ metaData -> get ( 'type' ) , $ metaData ) ; } catch ( \ InvalidArgumentException $ exception ) { throw new NotAcceptableHttpException ( $ exception -> getMessage ( ) ) ; } return $ this -> createJsonResponse ( [ $ this -> convertTaskToArray ( $ this -> getTensideTasks ( ) -> getTask ( $ taskId ) ) ] , false , 'OK' , JsonResponse :: HTTP_CREATED ) ; }
Queue a task in the list.

@param Request $request The request.

@return JsonResponse

@throws NotAcceptableHttpException When the payload is invalid.

@ApiDoc(
section="tasks",
statusCodes = {
201 = "When everything worked out ok",
406 = "When the payload is invalid"
},
authentication = true,
authenticationRoles = {
"ROLE_MANIPULATE_REQUIREMENTS"
},
)
@ApiDescription(
response={
"status" = {
"dataType" = "string",
"description" = "OK on success"
},
"task" = {
"id" = {
"dataType" = "string",
"description" = "The task id."
},
"status" = {
"dataType" = "string",
"description" = "The task status."
},
"type" = {
"dataType" = "string",
"description" = "The type of the task."
},
"user_data" = {
"dataType" = "object",
"description" = "The user submitted additional data."
},
"created_at" = {
"dataType" = "string",
"description" = "The date the task was created in ISO 8601 format."
}
}
}
)
Queue a task in the list .