You are here

public function AvatarBase::setType in Avatar Kit 8

Sets the avatar type.

Parameters

string $type: The avatar type.

Return value

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

Throws

\Drupal\avatars\Exception\AvatarException Thrown if this the type is not defined.

Overrides AvatarBaseInterface::setType

See also

\Drupal\avatars\AvatarBaseInterface::getTypes()

File

src/AvatarBase.php, line 115

Class

AvatarBase
Abstract class for Avatar APIs.

Namespace

Drupal\avatars

Code

public function setType($type) {
  if (!array_key_exists($type, $this
    ->getTypes())) {
    throw new AvatarException('Invalid type');
  }
  $this->type = $type;
  return $this;
}