original_string: public function searchUsersAction()
      {
          if (!$this->getRequest()->isXmlHttpRequest()) {
              throw new \RuntimeException('This action must be called via ajax request');
          }
          
          $model = new JsonModel();
          $query = $this->params()->fromPost('query', false);
          if (!$query) {
              $query = $this->params()->fromQuery('q', false);
          }
          if (false === $query) {
              $result = array();
          } else {
              $repositories = $this->repositories;
              $repository   = $repositories->get('Auth/User');
              
              $users = $repository->findByQuery($query);
          
              $userFilter = $this->filterManager->get('Auth/Entity/UserToSearchResult');
              $filterFunc = function ($user) use ($userFilter) {
                  return $userFilter->filter($user);
              };
              $result     = array_values(array_map($filterFunc, $users->toArray()));
          }
          
          //$model->setVariable('users', $result);
          $model->setVariables($result);
          return $model;
      }
code: public function searchUsersAction()
      {
          if (!$this->getRequest()->isXmlHttpRequest()) {
              throw new \RuntimeException('This action must be called via ajax request');
          }
          
          $model = new JsonModel();
          $query = $this->params()->fromPost('query', false);
          if (!$query) {
              $query = $this->params()->fromQuery('q', false);
          }
          if (false === $query) {
              $result = array();
          } else {
              $repositories = $this->repositories;
              $repository   = $repositories->get('Auth/User');
              
              $users = $repository->findByQuery($query);
          
              $userFilter = $this->filterManager->get('Auth/Entity/UserToSearchResult');
              $filterFunc = function ($user) use ($userFilter) {
                  return $userFilter->filter($user);
              };
              $result     = array_values(array_map($filterFunc, $users->toArray()));
          }
          
          //$model->setVariable('users', $result);
          $model->setVariables($result);
          return $model;
      }
code_tokens: public function searchUsersAction ( ) { if ( ! $ this -> getRequest ( ) -> isXmlHttpRequest ( ) ) { throw new \ RuntimeException ( 'This action must be called via ajax request' ) ; } $ model = new JsonModel ( ) ; $ query = $ this -> params ( ) -> fromPost ( 'query' , false ) ; if ( ! $ query ) { $ query = $ this -> params ( ) -> fromQuery ( 'q' , false ) ; } if ( false === $ query ) { $ result = array ( ) ; } else { $ repositories = $ this -> repositories ; $ repository = $ repositories -> get ( 'Auth/User' ) ; $ users = $ repository -> findByQuery ( $ query ) ; $ userFilter = $ this -> filterManager -> get ( 'Auth/Entity/UserToSearchResult' ) ; $ filterFunc = function ( $ user ) use ( $ userFilter ) { return $ userFilter -> filter ( $ user ) ; } ; $ result = array_values ( array_map ( $ filterFunc , $ users -> toArray ( ) ) ) ; } //$model->setVariable('users', $result); $ model -> setVariables ( $ result ) ; return $ model ; }
docstring: Helper action for userselect form element.
  
  @return \Zend\View\Model\JsonModel
docstring_tokens: Helper action for userselect form element .