public static function UserList::getFromParameters

8.0.x UserList.php public static UserList::getFromParameters($inputs)
7.x UserList.php public static UserList::getFromParameters($inputs)
master UserList.php public static UserList::getFromParameters($inputs)

Given a comma-separated list of inputs, return accounts for users that match by uid,name or email address.

Parameters

string $inputs: A comma delimited string (or array) of arguments, specifying user account(s).

Return value

\Drush\User\UserSingleBase[] An associative array of UserSingleBase objects, keyed by user id.

Throws

UserListException If any input is unmatched, an exception is thrown.

1 call to UserList::getFromParameters()
UserList::__construct in lib/Drush/User/UserList.php
Finds a list of user objects based on Drush arguments, or options.

File

lib/Drush/User/UserList.php, line 97

Namespace

Drush\User

Class

UserList

Code

public static function getFromParameters($inputs) {
  $accounts = array();
  $userversion = drush_user_get_class();
  if ($inputs && $userversion) {
    $inputs = _convert_csv_to_array($inputs);
    foreach ($inputs as $input) {
      if (is_numeric($input) && $account = $userversion->load_by_uid($input)) {

      }
      elseif ($account = $userversion->load_by_name($input)) {

      }
      elseif ($account = $userversion->load_by_mail($input)) {

      }
      else {
        // Unable to load an account for the input.
        throw new UserListException('Unable to find a matching user for ' . $input . '.');
      }
      // Populate $accounts with a UserSingle object. Will go into $this->accounts.
      $single = drush_usersingle_get_class($account);
      $accounts[$single->id()] = $single;
    }
  }
  return $accounts;
}