class GravatarGenerator in Avatar Kit 8
Gravatar generated avatars generator.
Plugin annotation
@AvatarGenerator(
id = "gravatar_generator",
label = @Translation("Gravatar generator"),
description = @Translation("Identicon, MonsterID, Retro, and Wavatar avatar generators."),
fallback = TRUE,
dynamic = FALSE,
remote = TRUE
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\avatars\Plugin\AvatarGenerator\AvatarGeneratorBase implements AvatarGeneratorPluginInterface
- class \Drupal\avatars_gravatar\Plugin\AvatarGenerator\GravatarGenerator uses StringTranslationTrait
- class \Drupal\avatars\Plugin\AvatarGenerator\AvatarGeneratorBase implements AvatarGeneratorPluginInterface
Expanded class hierarchy of GravatarGenerator
File
- avatars_gravatar/
src/ Plugin/ AvatarGenerator/ GravatarGenerator.php, line 23
Namespace
Drupal\avatars_gravatar\Plugin\AvatarGeneratorView source
class GravatarGenerator extends AvatarGeneratorBase {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [
'type' => '',
];
}
/**
* {@inheritdoc}
*/
public function generateUri(AccountInterface $account) {
$gravatar = new GravatarAPI();
return $gravatar
->setIdentifier($this
->getIdentifier($account))
->setType($this->configuration['type'])
->setDimensions(256)
->getUrl();
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['type'] = [
'#type' => 'radios',
'#title' => $this
->t('Type'),
'#options' => [
'identicon' => $this
->t('Identicon'),
'monsterid' => $this
->t('Monster ID'),
'wavatar' => $this
->t('Wavatar'),
'retro' => $this
->t('8-bit style avatar'),
],
'#default_value' => $this->configuration['type'],
];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this->configuration['type'] = $form_state
->getValue('type');
}
/**
* {@inheritdoc}
*/
public function settingsSummary() {
$summary = [];
if (empty($this->configuration['type'])) {
$summary[] = $this
->t('Missing Configuration');
}
else {
$summary[]['#markup'] = $this
->t('Type: @type', [
'@type' => $this->configuration['type'],
]);
}
return $summary;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AvatarGeneratorBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
AvatarGeneratorBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
AvatarGeneratorBase:: |
public | function |
Gets File object for an avatar. Overrides AvatarGeneratorPluginInterface:: |
1 |
AvatarGeneratorBase:: |
protected | function | Create a site-unique identifier for a user. | |
AvatarGeneratorBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
AvatarGeneratorBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
|
AvatarGeneratorBase:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
|
GravatarGenerator:: |
public | function |
Form constructor. Overrides AvatarGeneratorBase:: |
|
GravatarGenerator:: |
public | function |
Gets default configuration for this plugin. Overrides AvatarGeneratorBase:: |
|
GravatarGenerator:: |
public | function |
Creates a URI to an avatar. Overrides AvatarGeneratorBase:: |
|
GravatarGenerator:: |
public | function |
Generate a summary about the current configuration of the widget. Overrides AvatarGeneratorBase:: |
|
GravatarGenerator:: |
public | function |
Form submission handler. Overrides AvatarGeneratorBase:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |