Controller/TaskController.php
public function createTaskAction(Request $request)
    {
        $typeName = $request->get('type');
        $assignedUserId = $request->get('recipient');
        $description = $request->get('description');
        $payload = $request->get('payload');

        if ($payload) {
            $payload = json_decode($payload, true);
        }

        $taskManager = $this->get('phlexible_task.task_manager');
        $userManager = $this->get('phlexible_user.user_manager');
        $types = $this->get('phlexible_task.types');

        $type = $types->get($typeName);
        $assignedUser = $userManager->find($assignedUserId);

        $task = $taskManager->createTask($type, $this->getUser(), $assignedUser, $payload, $description);

        return new ResultResponse(true, 'Task created.');
    }
public function createTaskAction(Request $request)
    {
        $typeName = $request->get('type');
        $assignedUserId = $request->get('recipient');
        $description = $request->get('description');
        $payload = $request->get('payload');

        if ($payload) {
            $payload = json_decode($payload, true);
        }

        $taskManager = $this->get('phlexible_task.task_manager');
        $userManager = $this->get('phlexible_user.user_manager');
        $types = $this->get('phlexible_task.types');

        $type = $types->get($typeName);
        $assignedUser = $userManager->find($assignedUserId);

        $task = $taskManager->createTask($type, $this->getUser(), $assignedUser, $payload, $description);

        return new ResultResponse(true, 'Task created.');
    }
public function createTaskAction ( Request $ request ) { $ typeName = $ request -> get ( 'type' ) ; $ assignedUserId = $ request -> get ( 'recipient' ) ; $ description = $ request -> get ( 'description' ) ; $ payload = $ request -> get ( 'payload' ) ; if ( $ payload ) { $ payload = json_decode ( $ payload , true ) ; } $ taskManager = $ this -> get ( 'phlexible_task.task_manager' ) ; $ userManager = $ this -> get ( 'phlexible_user.user_manager' ) ; $ types = $ this -> get ( 'phlexible_task.types' ) ; $ type = $ types -> get ( $ typeName ) ; $ assignedUser = $ userManager -> find ( $ assignedUserId ) ; $ task = $ taskManager -> createTask ( $ type , $ this -> getUser ( ) , $ assignedUser , $ payload , $ description ) ; return new ResultResponse ( true , 'Task created.' ) ; }
Create task.

@param Request $request

@return ResultResponse
@Route("/create/task", name="tasks_create_task")
@Method({"GET", "POST"})
@ApiDoc(
description="Create task",
requirements={
{"name"="type", "dataType"="string", "required"=true, "description"="Task type"},
{"name"="recipient", "dataType"="string", "required"=true, "description"="Recipient"},
{"name"="description", "dataType"="string", "required"=true, "description"="Description"},
{"name"="payload", "dataType"="array", "required"=true, "description"="Payload"}
}
)
Create task .