You are here

interface AvatarManagerInterface in Avatar Kit 8

Provides an interface to the avatar manager service.

Hierarchy

Expanded class hierarchy of AvatarManagerInterface

All classes that implement AvatarManagerInterface

File

src/AvatarManagerInterface.php, line 11

Namespace

Drupal\avatars
View source
interface AvatarManagerInterface {

  /**
   * Check user avatar for changes, and inserts the avatar into the user entity.
   *
   * @param \Drupal\user\UserInterface $user
   *   A user entity.
   */
  public function syncAvatar(UserInterface $user);

  /**
   * Go down the the avatar generator preference hierarchy for a user.
   *
   * Loads each avatar until a valid avatar is found.
   *
   * @param \Drupal\user\UserInterface $user
   *   A user entity.
   *
   * @return \Drupal\avatars\AvatarPreviewInterface|null
   *   An avatar preview entity.
   */
  public function findValidAvatar(UserInterface $user);

  /**
   * Create avatar if it does not exist.
   *
   * @param \Drupal\user\UserInterface $user
   *   A user entity.
   * @param \Drupal\avatars\AvatarGeneratorInterface $avatar_generator
   *   An avatar generator instance.
   * @param int $scope
   *   Caching scope level.
   *
   * @return \Drupal\avatars\AvatarPreviewInterface|false
   *   An avatar preview entity.
   */
  public function refreshAvatarGenerator(UserInterface $user, AvatarGeneratorInterface $avatar_generator, $scope);

  /**
   * Downloads all avatar previews for a user.
   *
   * @param \Drupal\user\UserInterface $user
   *   A user entity.
   *
   * @return \Drupal\avatars\AvatarPreviewInterface[]
   *   An array of refreshed avatar preview entities.
   */
  public function refreshAllAvatars(UserInterface $user);

  /**
   * Download avatar and insert it into a file.
   *
   * Ignores any existing caches. Use refreshAvatarGenerator to take advantage
   * of internal caching.
   *
   * @param \Drupal\avatars\AvatarGeneratorInterface $avatar_generator
   *   An avatar generator instance.
   * @param \Drupal\user\UserInterface $user
   *   A user entity.
   *
   * @return \Drupal\file\FileInterface|false
   *   The file containing an avatar.
   */
  public function getAvatarFile(AvatarGeneratorInterface $avatar_generator, UserInterface $user);

  /**
   * Avatar preference generators.
   *
   * Ordered by priority.
   *
   * @param \Drupal\user\UserInterface $user
   *   A user entity.
   *
   * @return \Generator
   *   Generator yield pairs:
   *   key: string $avatar_generator_machine_name
   *   value: value of constants prefixed with AvatarPreviewInterface::SCOPE_*
   */
  public function getPreferences(UserInterface $user);

  /**
   * Invalidate any cache where the user avatar is displayed.
   *
   * Call if the avatar has changed, or is expected to change.
   *
   * @param \Drupal\user\UserInterface $user
   *   A user entity.
   */
  public function invalidateUserAvatar(UserInterface $user);

  /**
   * Triggers expected change for dynamic avatar generator.
   *
   * @param \Drupal\avatars\AvatarGeneratorInterface $avatar_generator
   *   An avatar generator instance.
   * @param \Drupal\user\UserInterface $user
   *   A user entity.
   */
  public function notifyDynamicChange(AvatarGeneratorInterface $avatar_generator, UserInterface $user);

  /**
   * Gets a lit of active plugins a user has permission to use.
   *
   * @param \Drupal\user\UserInterface $user
   *   A user entity.
   * @param bool $exclude_user_preference
   *   Exclude 'user preference' plugin types.
   *
   * @return \Drupal\avatars\AvatarGeneratorInterface[]|\Generator
   *   An array of avatar generator entities.
   */
  public function getAvatarGeneratorsForUser(UserInterface $user, $exclude_user_preference = TRUE);

  /**
   * Determines if a file entity is an avatar preview.
   *
   * @param \Drupal\file\FileInterface $file
   *   The file entity to check.
   *
   * @return int|false
   *   Returns the avatar preview entity ID, or FALSE if the file is not a
   *   avatar preview.
   */
  public function getAvatarPreviewByFile(FileInterface $file);

}

Members

Namesort descending Modifiers Type Description Overrides
AvatarManagerInterface::findValidAvatar public function Go down the the avatar generator preference hierarchy for a user. 1
AvatarManagerInterface::getAvatarFile public function Download avatar and insert it into a file. 1
AvatarManagerInterface::getAvatarGeneratorsForUser public function Gets a lit of active plugins a user has permission to use. 1
AvatarManagerInterface::getAvatarPreviewByFile public function Determines if a file entity is an avatar preview. 1
AvatarManagerInterface::getPreferences public function Avatar preference generators. 1
AvatarManagerInterface::invalidateUserAvatar public function Invalidate any cache where the user avatar is displayed. 1
AvatarManagerInterface::notifyDynamicChange public function Triggers expected change for dynamic avatar generator. 1
AvatarManagerInterface::refreshAllAvatars public function Downloads all avatar previews for a user. 1
AvatarManagerInterface::refreshAvatarGenerator public function Create avatar if it does not exist. 1
AvatarManagerInterface::syncAvatar public function Check user avatar for changes, and inserts the avatar into the user entity. 1