You are here

protected function AccountRegistration::generateUniqueUsername in SMS Framework 8

Same name and namespace in other branches
  1. 2.x modules/sms_user/src/AccountRegistration.php \Drupal\sms_user\AccountRegistration::generateUniqueUsername()
  2. 2.1.x modules/sms_user/src/AccountRegistration.php \Drupal\sms_user\AccountRegistration::generateUniqueUsername()

Generate a unique user name that is not being used.

Return value

string A unique user name.

2 calls to AccountRegistration::generateUniqueUsername()
AccountRegistration::allUnknownNumbers in modules/sms_user/src/AccountRegistration.php
Process incoming message and create a user if the phone number is unknown.
AccountRegistration::incomingPatternMessage in modules/sms_user/src/AccountRegistration.php
Creates a user if an incoming message contents matches a pattern.

File

modules/sms_user/src/AccountRegistration.php, line 343

Class

AccountRegistration
Defines the account registration service.

Namespace

Drupal\sms_user

Code

protected function generateUniqueUsername() {
  $random = new Random();
  do {
    $username = $random
      ->name(8, TRUE);
  } while (user_validate_name($username) || user_load_by_name($username));
  return $username;
}