You are here

interface GravatarInterface in Avatar Kit 8

Provides an interface for the Gravatar.com API.

Hierarchy

Expanded class hierarchy of GravatarInterface

All classes that implement GravatarInterface

File

avatars_gravatar/src/GravatarInterface.php, line 8

Namespace

Drupal\avatars_gravatar
View source
interface GravatarInterface {

  /*
   * URL for insecure requests.
   *
   * @var string
   */
  const GRAVATAR_HOSTNAME = 'gravatar.com';

  /*
   * URL for secure requests.
   *
   * @var string
   */
  const GRAVATAR_HOSTNAME_SECURE = 'secure.gravatar.com';

  /*
   * Minimum width images output by the endpoint.
   *
   * @var int
   */
  const DIMENSION_MINIMUM_WIDTH = 1;

  /*
   * Maximum width images output by the endpoint.
   *
   * @var int
   */
  const DIMENSION_MAXIMUM_WIDTH = 2048;

  /**
   * Avatar types mapped to 'd' GET values.
   *
   * @return array
   *   An array of GET values keyed by type.
   */
  public static function getTypesMap();

  /**
   * Valid fallback types for when 'gravatar' is the primary type.
   *
   * @return string[]
   *   An array of fallback avatar types.
   */
  public static function getFallbackTypes();

  /**
   * Get the fallback avatar type.
   *
   * @return string|null
   *   The fallback avatar type, or NULL to use default.
   */
  public function getFallbackType();

  /**
   * The type used for when 'gravatar' type fails.
   *
   * Such as when there is no Gravatar for the hash.
   *
   * @param string|null $type
   *   An avatar type.
   *
   * @throws \Drupal\avatars\Exception\AvatarException
   *   Thrown if the passed type is invalid.
   *
   * @return \Drupal\avatars_gravatar\GravatarInterface
   *   Returns the called object for chaining.
   */
  public function setFallbackType($type = NULL);

  /**
   * The URI to an image used for when 'gravatar' type fails.
   *
   * Such as when there is no Gravatar for the hash.
   *
   * @param string $uri
   *   The URI of an image to use as a fallback.
   *
   * @return \Drupal\avatars_gravatar\GravatarInterface
   *   Returns the called object for chaining.
   */
  public function setFallbackUri($uri);

  /**
   * Get a list of valid ratings.
   *
   * @return array
   *   An array of rating labels keyed by rating.
   */
  public static function getRatings();

  /**
   * Get the rating.
   *
   * @return string|null
   *   The set rating, or NULL if no rating.
   */
  public function getRating();

  /**
   * Sets the maximum gravatar rating.
   *
   * @param string|null $rating
   *   The rating to set, or NULL if no rating.
   *
   * @throws \Drupal\avatars\Exception\AvatarException
   *   Thrown if the rating is invalid.
   *
   * @return \Drupal\avatars_gravatar\GravatarInterface
   *   Returns the called object for chaining.
   */
  public function setRating($rating = NULL);

}

Members

Namesort descending Modifiers Type Description Overrides
GravatarInterface::DIMENSION_MAXIMUM_WIDTH constant
GravatarInterface::DIMENSION_MINIMUM_WIDTH constant
GravatarInterface::getFallbackType public function Get the fallback avatar type. 1
GravatarInterface::getFallbackTypes public static function Valid fallback types for when 'gravatar' is the primary type. 1
GravatarInterface::getRating public function Get the rating. 1
GravatarInterface::getRatings public static function Get a list of valid ratings. 1
GravatarInterface::getTypesMap public static function Avatar types mapped to 'd' GET values. 1
GravatarInterface::GRAVATAR_HOSTNAME constant
GravatarInterface::GRAVATAR_HOSTNAME_SECURE constant
GravatarInterface::setFallbackType public function The type used for when 'gravatar' type fails. 1
GravatarInterface::setFallbackUri public function The URI to an image used for when 'gravatar' type fails. 1
GravatarInterface::setRating public function Sets the maximum gravatar rating. 1