Controller/TaskController.php
public function recipientsAction(Request $request)
    {
        $taskType = $request->get('type');

        $types = $this->get('phlexible_task.types');
        $userManager = $this->get('phlexible_user.user_manager');
        $authorizationChecker = $this->get('security.authorization_checker');

        $type = $types->get($taskType);

        $users = [];
        foreach ($userManager->findAll() as $user) {
            if (!$authorizationChecker->isGranted('ROLE_TASKS')) {
                continue;
            }

            if ($type->getRole() && !$authorizationChecker->isGranted($type->getRole())) {
                continue;
            }

            $users[$user->getDisplayName()] = [
                'uid' => $user->getId(),
                'username' => $user->getDisplayName(),
            ];
        }

        ksort($users);
        $users = array_values($users);

        return new JsonResponse(['users' => $users]);
    }
public function recipientsAction(Request $request)
    {
        $taskType = $request->get('type');

        $types = $this->get('phlexible_task.types');
        $userManager = $this->get('phlexible_user.user_manager');
        $authorizationChecker = $this->get('security.authorization_checker');

        $type = $types->get($taskType);

        $users = [];
        foreach ($userManager->findAll() as $user) {
            if (!$authorizationChecker->isGranted('ROLE_TASKS')) {
                continue;
            }

            if ($type->getRole() && !$authorizationChecker->isGranted($type->getRole())) {
                continue;
            }

            $users[$user->getDisplayName()] = [
                'uid' => $user->getId(),
                'username' => $user->getDisplayName(),
            ];
        }

        ksort($users);
        $users = array_values($users);

        return new JsonResponse(['users' => $users]);
    }
public function recipientsAction ( Request $ request ) { $ taskType = $ request -> get ( 'type' ) ; $ types = $ this -> get ( 'phlexible_task.types' ) ; $ userManager = $ this -> get ( 'phlexible_user.user_manager' ) ; $ authorizationChecker = $ this -> get ( 'security.authorization_checker' ) ; $ type = $ types -> get ( $ taskType ) ; $ users = [ ] ; foreach ( $ userManager -> findAll ( ) as $ user ) { if ( ! $ authorizationChecker -> isGranted ( 'ROLE_TASKS' ) ) { continue ; } if ( $ type -> getRole ( ) && ! $ authorizationChecker -> isGranted ( $ type -> getRole ( ) ) ) { continue ; } $ users [ $ user -> getDisplayName ( ) ] = [ 'uid' => $ user -> getId ( ) , 'username' => $ user -> getDisplayName ( ) , ] ; } ksort ( $ users ) ; $ users = array_values ( $ users ) ; return new JsonResponse ( [ 'users' => $ users ] ) ; }
List recipients.

@param Request $request

@return JsonResponse
@Route("/recipients", name="tasks_recipients")
@Method({"GET", "POST"})
@ApiDoc(
description="List recipients",
requirements={
{"name"="type", "dataType"="string", "required"=true, "description"="Task type"},
}
)
List recipients .