public static function AvatarPreview::getAvatarPreview in Avatar Kit 8
Queries for an avatar preview and loads it.
Parameters
\Drupal\avatars\AvatarGeneratorInterface $avatar_generator: An avatar generator instance.
\Drupal\user\UserInterface $user: A user entity.
Return value
\Drupal\avatars\AvatarPreviewInterface|false An avatar preview entity, or FALSE if it does not exist.
Overrides AvatarPreviewInterface::getAvatarPreview
3 calls to AvatarPreview::getAvatarPreview()
- AvatarManager::findValidAvatar in src/
AvatarManager.php - Go down the the avatar generator preference hierarchy for a user.
- AvatarManager::notifyDynamicChange in src/
AvatarManager.php - Triggers expected change for dynamic avatar generator.
- AvatarManager::refreshAvatarGenerator in src/
AvatarManager.php - Create avatar if it does not exist.
File
- src/
Entity/ AvatarPreview.php, line 107
Class
- AvatarPreview
- Defines the avatar preview entity.
Namespace
Drupal\avatars\EntityCode
public static function getAvatarPreview(AvatarGeneratorInterface $avatar_generator, UserInterface $user) {
if ($user
->isNew()) {
return FALSE;
}
$entities = \Drupal::entityTypeManager()
->getStorage('avatars_preview')
->loadByProperties([
'avatar_generator' => $avatar_generator
->id(),
'uid' => $user
->id(),
]);
return reset($entities);
}