Controller/TaskController.php
public function listAction(Request $request)
    {
        $type = $request->request->get('tasks', 'involved');
        $sort = $request->request->get('sort', 'createdAt');
        $dir = $request->request->get('dir', 'DESC');
        $limit = $request->request->get('limit', 20);
        $start = $request->request->get('start', 0);

        $status = [];
        foreach ($request->request->all() as $key => $value) {
            if (substr($key, 0, 7) === 'status_') {
                $status[] = substr($key, 7);
            }
        }

        $taskManager = $this->get('phlexible_task.task_manager');

        if (!count($status)) {
            $status[] = current(array_keys($taskManager->getStates()));
        }

        $userId = $this->getUser()->getId();

        switch ($type) {
            case 'tasks':
                $tasks = $taskManager->findByCreatedByAndStatus($userId, $status, [$sort => $dir], $limit, $start);
                $total = $taskManager->countByCreatedByAndStatus($userId, $status);
                break;

            case 'todos':
                $tasks = $taskManager->findByAssignedToAndStatus($userId, $status, [$sort => $dir], $limit, $start);
                $total = $taskManager->countByAssignedToAndStatus($userId, $status);
                break;

            case 'involved':
                $tasks = $taskManager->findByInvolvementAndStatus($userId, $status, [$sort => $dir], $limit, $start);
                $total = $taskManager->countByInvolvementAndStatus($userId, $status);
                break;

            case 'all':
            default:
                $tasks = $taskManager->findByStatus($status, [$sort => $dir], $limit, $start);
                $total = $taskManager->countByStatus($status);
                break;
        }

        $data = [];
        foreach ($tasks as $task) {
            /* @var $task Task */
            $data[] = $this->serializeTask($task);
        }

        return new JsonResponse([
            'tasks' => $data,
            'total' => $total,
        ]);
    }
public function listAction(Request $request)
    {
        $type = $request->request->get('tasks', 'involved');
        $sort = $request->request->get('sort', 'createdAt');
        $dir = $request->request->get('dir', 'DESC');
        $limit = $request->request->get('limit', 20);
        $start = $request->request->get('start', 0);

        $status = [];
        foreach ($request->request->all() as $key => $value) {
            if (substr($key, 0, 7) === 'status_') {
                $status[] = substr($key, 7);
            }
        }

        $taskManager = $this->get('phlexible_task.task_manager');

        if (!count($status)) {
            $status[] = current(array_keys($taskManager->getStates()));
        }

        $userId = $this->getUser()->getId();

        switch ($type) {
            case 'tasks':
                $tasks = $taskManager->findByCreatedByAndStatus($userId, $status, [$sort => $dir], $limit, $start);
                $total = $taskManager->countByCreatedByAndStatus($userId, $status);
                break;

            case 'todos':
                $tasks = $taskManager->findByAssignedToAndStatus($userId, $status, [$sort => $dir], $limit, $start);
                $total = $taskManager->countByAssignedToAndStatus($userId, $status);
                break;

            case 'involved':
                $tasks = $taskManager->findByInvolvementAndStatus($userId, $status, [$sort => $dir], $limit, $start);
                $total = $taskManager->countByInvolvementAndStatus($userId, $status);
                break;

            case 'all':
            default:
                $tasks = $taskManager->findByStatus($status, [$sort => $dir], $limit, $start);
                $total = $taskManager->countByStatus($status);
                break;
        }

        $data = [];
        foreach ($tasks as $task) {
            /* @var $task Task */
            $data[] = $this->serializeTask($task);
        }

        return new JsonResponse([
            'tasks' => $data,
            'total' => $total,
        ]);
    }
public function listAction ( Request $ request ) { $ type = $ request -> request -> get ( 'tasks' , 'involved' ) ; $ sort = $ request -> request -> get ( 'sort' , 'createdAt' ) ; $ dir = $ request -> request -> get ( 'dir' , 'DESC' ) ; $ limit = $ request -> request -> get ( 'limit' , 20 ) ; $ start = $ request -> request -> get ( 'start' , 0 ) ; $ status = [ ] ; foreach ( $ request -> request -> all ( ) as $ key => $ value ) { if ( substr ( $ key , 0 , 7 ) === 'status_' ) { $ status [ ] = substr ( $ key , 7 ) ; } } $ taskManager = $ this -> get ( 'phlexible_task.task_manager' ) ; if ( ! count ( $ status ) ) { $ status [ ] = current ( array_keys ( $ taskManager -> getStates ( ) ) ) ; } $ userId = $ this -> getUser ( ) -> getId ( ) ; switch ( $ type ) { case 'tasks' : $ tasks = $ taskManager -> findByCreatedByAndStatus ( $ userId , $ status , [ $ sort => $ dir ] , $ limit , $ start ) ; $ total = $ taskManager -> countByCreatedByAndStatus ( $ userId , $ status ) ; break ; case 'todos' : $ tasks = $ taskManager -> findByAssignedToAndStatus ( $ userId , $ status , [ $ sort => $ dir ] , $ limit , $ start ) ; $ total = $ taskManager -> countByAssignedToAndStatus ( $ userId , $ status ) ; break ; case 'involved' : $ tasks = $ taskManager -> findByInvolvementAndStatus ( $ userId , $ status , [ $ sort => $ dir ] , $ limit , $ start ) ; $ total = $ taskManager -> countByInvolvementAndStatus ( $ userId , $ status ) ; break ; case 'all' : default : $ tasks = $ taskManager -> findByStatus ( $ status , [ $ sort => $ dir ] , $ limit , $ start ) ; $ total = $ taskManager -> countByStatus ( $ status ) ; break ; } $ data = [ ] ; foreach ( $ tasks as $ task ) { /* @var $task Task */ $ data [ ] = $ this -> serializeTask ( $ task ) ; } return new JsonResponse ( [ 'tasks' => $ data , 'total' => $ total , ] ) ; }
List tasks.

@param Request $request

@return JsonResponse
@Route("/list", name="tasks_list")
@Method({"GET", "POST"})
@ApiDoc(
description="Search",
requirements={
{"name"="query", "dataType"="string", "required"=true, "description"="Search query"}
},
filters={
{"name"="limit", "dataType"="integer", "default"=20, "description"="Limit results"},
{"name"="start", "dataType"="integer", "default"=0, "description"="Result offset"},
{"name"="sort", "dataType"="string", "default"="created_at", "description"="Sort field"},
{"name"="dir", "dataType"="string", "default"="DESC", "description"="Sort direction"},
{"name"="tasks", "dataType"="string", "default"="involved", "description"="involvement"},
{"name"="status_open", "dataType"="boolean", "default"=false, "description"="Status open"},
{"name"="status_rejected", "dataType"="boolean", "default"=false, "description"="Status rejected"},
{"name"="status_reopened", "dataType"="boolean", "default"=false, "description"="Status reopened"},
{"name"="status_finished", "dataType"="boolean", "default"=false, "description"="Status finished"},
{"name"="status_closed", "dataType"="boolean", "default"=false, "description"="Status closed"}
}
)
List tasks .