/** * Given a comma-separated list of inputs, return accounts * for users that match by uid,name or email address. * * @param string $inputs * A comma delimited string (or array) of arguments, specifying user account(s). * * @throws UserListException * If any input is unmatched, an exception is thrown. * * @return \Drush\User\UserSingleBase[] * An associative array of UserSingleBase objects, keyed by user id. */ 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; }
/** * Load the current user account and return a UserSingle instance. * * @return \Drush\User\UserSingleBase * A Drush UserSingle instance. */ public function getCurrentUserAsSingle() { return drush_usersingle_get_class($this->getCurrentUserAsAccount()); }