getRepository('ChamiloUserBundle:User'); $users = $repo->findUsersToSendMessage( api_get_user_id(), $_REQUEST['q'], $_REQUEST['page_limit'] ); $showEmail = api_get_setting('show_email_addresses') === 'true'; $return = ['items' => []]; /** @var User $user */ foreach ($users as $user) { $userName = $user->getCompleteName(); if ($showEmail) { $userName .= " ({$user->getEmail()})"; } $return['items'][] = [ 'text' => $userName, 'id' => $user->getId() ]; } echo json_encode($return); break; default: echo ''; } exit;