public function byUsernameAction(Request $request)
   {
       $term = $request->get('username');
       $users = $this->get('asf_user.user.manager')->getRepository()->findByUsernameContains($term);
       $search = array();
       	
       foreach($users as $user) {
           $search[] = array(
               'id' => $user->getId(),
               'username' => $user->getUsername(),
               'email' => $user->getEmail()
           );
       }
       
       $response = new Response();
       $response->setContent(json_encode(array(
           'total_count' => count($search),
           'items' => $search
       )));
       
       return $response;
   }
public function byUsernameAction(Request $request)
   {
       $term = $request->get('username');
       $users = $this->get('asf_user.user.manager')->getRepository()->findByUsernameContains($term);
       $search = array();
       	
       foreach($users as $user) {
           $search[] = array(
               'id' => $user->getId(),
               'username' => $user->getUsername(),
               'email' => $user->getEmail()
           );
       }
       
       $response = new Response();
       $response->setContent(json_encode(array(
           'total_count' => count($search),
           'items' => $search
       )));
       
       return $response;
   }
public function byUsernameAction ( Request $ request ) { $ term = $ request -> get ( 'username' ) ; $ users = $ this -> get ( 'asf_user.user.manager' ) -> getRepository ( ) -> findByUsernameContains ( $ term ) ; $ search = array ( ) ; foreach ( $ users as $ user ) { $ search [ ] = array ( 'id' => $ user -> getId ( ) , 'username' => $ user -> getUsername ( ) , 'email' => $ user -> getEmail ( ) ) ; } $ response = new Response ( ) ; $ response -> setContent ( json_encode ( array ( 'total_count' => count ( $ search ) , 'items' => $ search ) ) ) ; return $ response ; }
Return list of users according to the search by username

@param Request $request
@return \Symfony\Component\HttpFoundation\Response
Return list of users according to the search by username