class Adorable in Avatar Kit 8
Same name in this branch
- 8 avatars_adorable/src/Adorable.php \Drupal\avatars_adorable\Adorable
- 8 avatars_adorable/src/Plugin/AvatarGenerator/Adorable.php \Drupal\avatars_adorable\Plugin\AvatarGenerator\Adorable
Implements the Adorable.io API.
Hierarchy
- class \Drupal\avatars\AvatarBase implements AvatarBaseInterface
- class \Drupal\avatars_adorable\Adorable implements AdorableInterface
Expanded class hierarchy of Adorable
1 file declares its use of Adorable
- Adorable.php in avatars_adorable/
src/ Plugin/ AvatarGenerator/ Adorable.php
1 string reference to 'Adorable'
- avatars_adorable.info.yml in avatars_adorable/
avatars_adorable.info.yml - avatars_adorable/avatars_adorable.info.yml
File
- avatars_adorable/
src/ Adorable.php, line 11
Namespace
Drupal\avatars_adorableView source
class Adorable extends AvatarBase implements AdorableInterface {
/**
* Constructs a new Adorable object.
*/
public function __construct() {
$this
->setDimensionConstraints(Adorable::DIMENSION_MINIMUM_WIDTH, Adorable::DIMENSION_MAXIMUM_WIDTH);
}
/**
* {@inheritdoc}
*/
public function getHostName() {
$hostname = parent::getHostName();
return isset($hostname) ? $hostname : $this::ADORABLE_HOSTNAME;
}
/**
* {@inheritdoc}
*/
public static function getTypes() {
return [
'adorable' => 'Adorables',
];
}
/**
* {@inheritdoc}
*/
public function setIsSecure($secure_request = TRUE) {
if ($secure_request) {
throw new AvatarException('Adorable does not support secure requests.');
}
return parent::setIsSecure($secure_request);
}
/**
* {@inheritdoc}
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Adorable:: |
public | function |
Gets the request host name. Overrides AvatarBase:: |
|
Adorable:: |
public static | function |
Gets list of avatar types provided by this API. Overrides AvatarBaseInterface:: |
|
Adorable:: |
public | function |
Gets the URL for the avatar. Overrides AvatarBaseInterface:: |
|
Adorable:: |
public | function |
Sets the request to secure. Overrides AvatarBase:: |
|
Adorable:: |
public | function | Constructs a new Adorable object. | |
AdorableInterface:: |
constant | |||
AdorableInterface:: |
constant | |||
AdorableInterface:: |
constant | |||
AvatarBase:: |
protected | property | Maximum height of the avatar. | |
AvatarBase:: |
protected | property | Minimum height of the avatar. | |
AvatarBase:: |
protected | property | Maximum width of the avatar. | |
AvatarBase:: |
protected | property | Minimum width of the avatar. | |
AvatarBase:: |
protected | property | Height. | |
AvatarBase:: |
protected | property | Host name. | |
AvatarBase:: |
protected | property | Identifier. | |
AvatarBase:: |
protected | property | Prehashed. | |
AvatarBase:: |
protected | property | Is Secure. | |
AvatarBase:: |
protected | property | Type. | |
AvatarBase:: |
protected | property | Width. | |
AvatarBase:: |
public | function |
Gets the identifier. Overrides AvatarBaseInterface:: |
|
AvatarBase:: |
public | function |
Gets the avatar type. Overrides AvatarBaseInterface:: |
|
AvatarBase:: |
public static | function |
Prepare an identifier for transmission to a third party. Overrides AvatarBaseInterface:: |
1 |
AvatarBase:: |
public | function |
Determines if the set identifier was prehashed. Overrides AvatarBaseInterface:: |
|
AvatarBase:: |
public | function |
Whether the URL will be secure. Overrides AvatarBaseInterface:: |
|
AvatarBase:: |
protected | function | Sets constraints for avatar dimensions. | |
AvatarBase:: |
public | function |
Sets dimensions to get form the endpoint. Overrides AvatarBaseInterface:: |
|
AvatarBase:: |
public | function |
Sets the request host name. Overrides AvatarBaseInterface:: |
|
AvatarBase:: |
public | function |
Sets a unique identifier to be passed to the API. Overrides AvatarBaseInterface:: |
1 |
AvatarBase:: |
public | function |
Sets the avatar type. Overrides AvatarBaseInterface:: |