You are here

public function AvatarBase::setIdentifier in Avatar Kit 8

Sets a unique identifier to be passed to the API.

Parameters

string $identifier: A unique identifier, such as an e-mail address.

bool $pre_hashed: Whether the ID has been pre-obfuscated, otherwise it will happen when the URL is generated.

Return value

\Drupal\avatars\AvatarBaseInterface Returns the called Robohash object for chaining.

Throws

\Drupal\avatars\Exception\AvatarException Thrown if the identifier is malformed.

Overrides AvatarBaseInterface::setIdentifier

1 call to AvatarBase::setIdentifier()
Gravatar::setIdentifier in avatars_gravatar/src/Gravatar.php
Sets a unique identifier to be passed to the API.
1 method overrides AvatarBase::setIdentifier()
Gravatar::setIdentifier in avatars_gravatar/src/Gravatar.php
Sets a unique identifier to be passed to the API.

File

src/AvatarBase.php, line 140

Class

AvatarBase
Abstract class for Avatar APIs.

Namespace

Drupal\avatars

Code

public function setIdentifier($identifier, $pre_hashed = FALSE) {
  if (!is_scalar($identifier)) {
    throw new AvatarException('Invalid identifier');
  }
  $this->identifier = $identifier;
  $this->prehashed = $pre_hashed;
  return $this;
}