public function Adorable::getUrl in Avatar Kit 8
Gets the URL for the avatar.
Return value
string A URL for an avatar.
Throws
\Drupal\avatars\Exception\AvatarException Thrown if missing parameters.
Overrides AvatarBaseInterface::getUrl
File
- avatars_adorable/
src/ Adorable.php, line 53
Class
- Adorable
- Implements the Adorable.io API.
Namespace
Drupal\avatars_adorableCode
public function getUrl() {
$url = ($this
->isSecure() ? 'https://' : 'http://') . $this
->getHostName() . '/avatars/';
// Width can be omitted.
if (is_numeric($this->width)) {
$url .= $this->width . '/';
}
$identifier = $this
->getIdentifier();
if (!strlen($identifier)) {
throw new AvatarException('Missing avatar identifier/hash');
}
$url .= $this
->identifierIsPreHashed() ? $identifier : $this
->hashIdentifier($identifier);
return $url;
}