Controller/TaskController.php
public function viewAction(Request $request)
    {
        $id = $request->get('id');

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

        $task = $taskManager->find($id);

        $createUser = $userManager->find($task->getCreateUserId());
        $assignedUser = $userManager->find($task->getAssignedUserId());

        $transitions = [];
        foreach ($task->getTransitions() as $transition) {
            $transitionUser = $userManager->find($transition->getCreateUserId());
            $history[] = [
                'create_date' => $transition->getCreatedAt()->format('Y-m-d H:i:s'),
                'name' => $transitionUser->getDisplayName(),
                'status' => $transition->getNewState(),
                'latest' => 1,
            ];
        }
        $transitions = array_reverse($transitions);

        $comments = [];
        foreach ($task->getComments() as $comment) {
            $commentUser = $userManager->find($comment->getCreateUserId());
            $history[] = [
                'create_date' => $comment->getCreatedAt()->format('Y-m-d H:i:s'),
                'name' => $commentUser->getDisplayName(),
                'status' => $comment->getCurrentState(),
                'comment' => $comment->getComment(),
                'latest' => 1,
            ];
        }

        $type = $types->get($task->getType());

        $data = [
            'id' => $task->getId(),
            'type' => $task->getType(),
            'title' => $type->getTitle($task),
            'text' => $type->getText($task),
            'component' => $type->getComponent(),
            'created' => $task->getCreateUserId() === $this->getUser()->getId() ? 1 : 0,
            'assigned' => $task->getAssignedUserId() === $this->getUser()->getId() ? 1 : 0,
            'assigned_user' => $assignedUser->getDisplayName(),
            'assigned_uid' => $task->getAssignedUserId(),
            'create_user' => $createUser->getDisplayName(),
            'create_uid' => $task->getCreateUserId(),
            'create_date' => $task->getCreatedAt()->format('Y-m-d H:i:s'),
            'latest_status' => $task->getFiniteState(),
            'latest_comment' => '', //$latestStatus->getComment(),
            'latest_user' => '', //$assignedUser->getDisplayName(),
            'latest_uid' => '', //$latestStatus->getCreateUserId(),
            'latest_date' => '', //$latestStatus->getCreatedAt()->format('Y-m-d H:i:s'),
            //'recipient_uid'  => $task->getRecipientUserId(),
            //'latest_id'      => $latestStatus->getId(),
            'transitions' => $transitions,
            'comments' => $comments,
        ];

        return new JsonResponse($data);
    }
public function viewAction(Request $request)
    {
        $id = $request->get('id');

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

        $task = $taskManager->find($id);

        $createUser = $userManager->find($task->getCreateUserId());
        $assignedUser = $userManager->find($task->getAssignedUserId());

        $transitions = [];
        foreach ($task->getTransitions() as $transition) {
            $transitionUser = $userManager->find($transition->getCreateUserId());
            $history[] = [
                'create_date' => $transition->getCreatedAt()->format('Y-m-d H:i:s'),
                'name' => $transitionUser->getDisplayName(),
                'status' => $transition->getNewState(),
                'latest' => 1,
            ];
        }
        $transitions = array_reverse($transitions);

        $comments = [];
        foreach ($task->getComments() as $comment) {
            $commentUser = $userManager->find($comment->getCreateUserId());
            $history[] = [
                'create_date' => $comment->getCreatedAt()->format('Y-m-d H:i:s'),
                'name' => $commentUser->getDisplayName(),
                'status' => $comment->getCurrentState(),
                'comment' => $comment->getComment(),
                'latest' => 1,
            ];
        }

        $type = $types->get($task->getType());

        $data = [
            'id' => $task->getId(),
            'type' => $task->getType(),
            'title' => $type->getTitle($task),
            'text' => $type->getText($task),
            'component' => $type->getComponent(),
            'created' => $task->getCreateUserId() === $this->getUser()->getId() ? 1 : 0,
            'assigned' => $task->getAssignedUserId() === $this->getUser()->getId() ? 1 : 0,
            'assigned_user' => $assignedUser->getDisplayName(),
            'assigned_uid' => $task->getAssignedUserId(),
            'create_user' => $createUser->getDisplayName(),
            'create_uid' => $task->getCreateUserId(),
            'create_date' => $task->getCreatedAt()->format('Y-m-d H:i:s'),
            'latest_status' => $task->getFiniteState(),
            'latest_comment' => '', //$latestStatus->getComment(),
            'latest_user' => '', //$assignedUser->getDisplayName(),
            'latest_uid' => '', //$latestStatus->getCreateUserId(),
            'latest_date' => '', //$latestStatus->getCreatedAt()->format('Y-m-d H:i:s'),
            //'recipient_uid'  => $task->getRecipientUserId(),
            //'latest_id'      => $latestStatus->getId(),
            'transitions' => $transitions,
            'comments' => $comments,
        ];

        return new JsonResponse($data);
    }
public function viewAction ( Request $ request ) { $ id = $ request -> get ( 'id' ) ; $ taskManager = $ this -> get ( 'phlexible_task.task_manager' ) ; $ types = $ this -> get ( 'phlexible_task.types' ) ; $ userManager = $ this -> get ( 'phlexible_user.user_manager' ) ; $ task = $ taskManager -> find ( $ id ) ; $ createUser = $ userManager -> find ( $ task -> getCreateUserId ( ) ) ; $ assignedUser = $ userManager -> find ( $ task -> getAssignedUserId ( ) ) ; $ transitions = [ ] ; foreach ( $ task -> getTransitions ( ) as $ transition ) { $ transitionUser = $ userManager -> find ( $ transition -> getCreateUserId ( ) ) ; $ history [ ] = [ 'create_date' => $ transition -> getCreatedAt ( ) -> format ( 'Y-m-d H:i:s' ) , 'name' => $ transitionUser -> getDisplayName ( ) , 'status' => $ transition -> getNewState ( ) , 'latest' => 1 , ] ; } $ transitions = array_reverse ( $ transitions ) ; $ comments = [ ] ; foreach ( $ task -> getComments ( ) as $ comment ) { $ commentUser = $ userManager -> find ( $ comment -> getCreateUserId ( ) ) ; $ history [ ] = [ 'create_date' => $ comment -> getCreatedAt ( ) -> format ( 'Y-m-d H:i:s' ) , 'name' => $ commentUser -> getDisplayName ( ) , 'status' => $ comment -> getCurrentState ( ) , 'comment' => $ comment -> getComment ( ) , 'latest' => 1 , ] ; } $ type = $ types -> get ( $ task -> getType ( ) ) ; $ data = [ 'id' => $ task -> getId ( ) , 'type' => $ task -> getType ( ) , 'title' => $ type -> getTitle ( $ task ) , 'text' => $ type -> getText ( $ task ) , 'component' => $ type -> getComponent ( ) , 'created' => $ task -> getCreateUserId ( ) === $ this -> getUser ( ) -> getId ( ) ? 1 : 0 , 'assigned' => $ task -> getAssignedUserId ( ) === $ this -> getUser ( ) -> getId ( ) ? 1 : 0 , 'assigned_user' => $ assignedUser -> getDisplayName ( ) , 'assigned_uid' => $ task -> getAssignedUserId ( ) , 'create_user' => $ createUser -> getDisplayName ( ) , 'create_uid' => $ task -> getCreateUserId ( ) , 'create_date' => $ task -> getCreatedAt ( ) -> format ( 'Y-m-d H:i:s' ) , 'latest_status' => $ task -> getFiniteState ( ) , 'latest_comment' => '' , //$latestStatus->getComment(), 'latest_user' => '' , //$assignedUser->getDisplayName(), 'latest_uid' => '' , //$latestStatus->getCreateUserId(), 'latest_date' => '' , //$latestStatus->getCreatedAt()->format('Y-m-d H:i:s'), //'recipient_uid'  => $task->getRecipientUserId(), //'latest_id'      => $latestStatus->getId(), 'transitions' => $ transitions , 'comments' => $ comments , ] ; return new JsonResponse ( $ data ) ; }
View task.

@param Request $request

@return JsonResponse
@Route("/view", name="tasks_view")
@Method({"GET", "POST"})
@ApiDoc(
description="View",
requirements={
{"name"="id", "dataType"="string", "required"=true, "description"="Task ID"}
}
)
View task .