You are here

protected function AvatarGeneratorBase::getIdentifier in Avatar Kit 8

Create a site-unique identifier for a user.

Parameters

\Drupal\Core\Session\AccountInterface $account: A user account.

Return value

string A unique string based on the user.

File

src/Plugin/AvatarGenerator/AvatarGeneratorBase.php, line 78

Class

AvatarGeneratorBase
AvatarGenerator plugin base class.

Namespace

Drupal\avatars\Plugin\AvatarGenerator

Code

protected function getIdentifier(AccountInterface $account) {

  // There is no ID for new users (registration page).
  if ($account
    ->isNew()) {
    return '0';
  }
  else {
    return !empty($account
      ->getEmail()) ? $account
      ->getEmail() : (string) $account
      ->id();
  }
}