class Gravatar in Avatar Kit 8
Same name in this branch
- 8 avatars_gravatar/src/Gravatar.php \Drupal\avatars_gravatar\Gravatar
- 8 avatars_gravatar/src/Plugin/AvatarGenerator/Gravatar.php \Drupal\avatars_gravatar\Plugin\AvatarGenerator\Gravatar
Gravatar avatar generator.
Plugin annotation
@AvatarGenerator(
id = "gravatar",
label = @Translation("Gravatar"),
description = @Translation("Universal avatar uploaded to Gravatar.com"),
fallback = FALSE,
dynamic = TRUE,
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\Gravatar uses StringTranslationTrait
- class \Drupal\avatars\Plugin\AvatarGenerator\AvatarGeneratorBase implements AvatarGeneratorPluginInterface
Expanded class hierarchy of Gravatar
3 string references to 'Gravatar'
- avatars_gravatar.info.yml in avatars_gravatar/
avatars_gravatar.info.yml - avatars_gravatar/avatars_gravatar.info.yml
- avatars_gravatar.schema.yml in avatars_gravatar/
config/ schema/ avatars_gravatar.schema.yml - avatars_gravatar/config/schema/avatars_gravatar.schema.yml
- Gravatar::getTypes in avatars_gravatar/
src/ Gravatar.php - Gets list of avatar types provided by this API.
File
- avatars_gravatar/
src/ Plugin/ AvatarGenerator/ Gravatar.php, line 23
Namespace
Drupal\avatars_gravatar\Plugin\AvatarGeneratorView source
class Gravatar extends AvatarGeneratorBase {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [
'maximum_rating' => '',
];
}
/**
* {@inheritdoc}
*/
public function generateUri(AccountInterface $account) {
$gravatar = new GravatarAPI();
if (!empty($this->configuration['maximum_rating'])) {
$gravatar
->setRating($this->configuration['maximum_rating']);
}
return $gravatar
->setIdentifier($this
->getIdentifier($account))
->setType('gravatar')
->setFallbackType('404')
->setDimensions(256)
->getUrl();
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['maximum_rating'] = [
'#type' => 'radios',
'#title' => $this
->t('Maximum content rating'),
'#options' => [
'' => $this
->t('Unrestricted'),
'g' => $this
->t('G: suitable for display on all websites with any audience type.'),
'pg' => $this
->t('PG: may contain rude gestures, provocatively dressed individuals, the lesser swear words, or mild violence.'),
'r' => $this
->t('R: may contain such things as harsh profanity, intense violence, nudity, or hard drug use.'),
'x' => $this
->t('X: may contain hardcore sexual imagery or extremely disturbing violence.'),
],
'#required' => TRUE,
'#default_value' => $this->configuration['maximum_rating'],
];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this->configuration['maximum_rating'] = $form_state
->getValue('maximum_rating');
}
/**
* {@inheritdoc}
*/
public function settingsSummary() {
$summary = [];
if (!empty($this->configuration['maximum_rating'])) {
$summary[]['#markup'] = $this
->t('Maximum rating: @maximum_rating', [
'@maximum_rating' => $this->configuration['maximum_rating'],
]);
}
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:: |
|
Gravatar:: |
public | function |
Form constructor. Overrides AvatarGeneratorBase:: |
|
Gravatar:: |
public | function |
Gets default configuration for this plugin. Overrides AvatarGeneratorBase:: |
|
Gravatar:: |
public | function |
Creates a URI to an avatar. Overrides AvatarGeneratorBase:: |
|
Gravatar:: |
public | function |
Generate a summary about the current configuration of the widget. Overrides AvatarGeneratorBase:: |
|
Gravatar:: |
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. |