public function Robohash::generateUri in Avatar Kit 8
Creates a URI to an avatar.
Parameters
\Drupal\Core\Session\AccountInterface $account: A user account.
Return value
string URI to an image file.
Overrides AvatarGeneratorBase::generateUri
File
- avatars_robohash/
src/ Plugin/ AvatarGenerator/ Robohash.php, line 40  
Class
- Robohash
 - Robohash avatar generator.
 
Namespace
Drupal\avatars_robohash\Plugin\AvatarGeneratorCode
public function generateUri(AccountInterface $account) {
  $robohash = new RobohashAPI();
  $type_map = [
    'robots' => 'robot',
    'robot_heads' => 'robot_head',
    'monsters' => 'monster',
  ];
  $type = $this->configuration['type'];
  $background_map = [
    'transparent' => 'transparent',
    'background_1' => 'places',
    'background_2' => 'patterns',
  ];
  $background = $this->configuration['background'];
  return $robohash
    ->setIdentifier($this
    ->getIdentifier($account))
    ->setType(isset($type_map[$type]) ? $type_map[$type] : '')
    ->setBackground(isset($background_map[$background]) ? $background_map[$background] : '')
    ->getUrl();
}