You are here

public function UserManager::createAccount in Open Social 8.6

Same name and namespace in other branches
  1. 8.9 modules/custom/social_auth_extra/src/UserManager.php \Drupal\social_auth_extra\UserManager::createAccount()
  2. 8 modules/custom/social_auth_extra/src/UserManager.php \Drupal\social_auth_extra\UserManager::createAccount()
  3. 8.2 modules/custom/social_auth_extra/src/UserManager.php \Drupal\social_auth_extra\UserManager::createAccount()
  4. 8.3 modules/custom/social_auth_extra/src/UserManager.php \Drupal\social_auth_extra\UserManager::createAccount()
  5. 8.4 modules/custom/social_auth_extra/src/UserManager.php \Drupal\social_auth_extra\UserManager::createAccount()
  6. 8.5 modules/custom/social_auth_extra/src/UserManager.php \Drupal\social_auth_extra\UserManager::createAccount()
  7. 8.7 modules/custom/social_auth_extra/src/UserManager.php \Drupal\social_auth_extra\UserManager::createAccount()
  8. 8.8 modules/custom/social_auth_extra/src/UserManager.php \Drupal\social_auth_extra\UserManager::createAccount()

Creates object of a new account.

Parameters

array $values: Additional fields to save in the created account.

Return value

\Drupal\Core\Entity\EntityInterface Object of a new user account.

Overrides UserManagerInterface::createAccount

File

modules/custom/social_auth_extra/src/UserManager.php, line 75

Class

UserManager
Class UserManager.

Namespace

Drupal\social_auth_extra

Code

public function createAccount(array $values = []) {
  $langcode = $this->languageManager
    ->getCurrentLanguage()
    ->getId();
  $values = array_merge([
    'name' => '',
    'mail' => '',
    'init' => '',
    'pass' => NULL,
    'status' => 1,
    'langcode' => $langcode,
    'preferred_langcode' => $langcode,
    'preferred_admin_langcode' => $langcode,
  ], $values);
  $this->account = $this->entityTypeManager
    ->getStorage('user')
    ->create($values);
  return $this->account;
}