You are here

interface AvatarBaseInterface in Avatar Kit 8

Interface for Avatar APIs.

Hierarchy

Expanded class hierarchy of AvatarBaseInterface

All classes that implement AvatarBaseInterface

File

src/AvatarBaseInterface.php, line 8

Namespace

Drupal\avatars
View source
interface AvatarBaseInterface {

  /**
   * Gets the request host name.
   *
   * @return string
   *   A host name.
   */
  public function getHostName();

  /**
   * Sets the request host name.
   *
   * @param string|null $hostname
   *   A host name, or NULL to reset to default.
   *
   * @return \Drupal\avatars\AvatarBaseInterface
   *   Returns the called Robohash object for chaining.
   */
  public function setHostName($hostname = NULL);

  /**
   * Gets the identifier.
   *
   * @return string
   *   The identifier.
   */
  public function getIdentifier();

  /**
   * Sets a unique identifier to be passed to the API.
   *
   * @param string $identifier
   *   A unique identifier, such as an e-mail address.
   * @param bool $pre_hashed
   *   Whether the ID has been pre-obfuscated, otherwise it will happen when the
   *   URL is generated.
   *
   * @throws \Drupal\avatars\Exception\AvatarException
   *   Thrown if the identifier is malformed.
   *
   * @return \Drupal\avatars\AvatarBaseInterface
   *   Returns the called Robohash object for chaining.
   */
  public function setIdentifier($identifier, $pre_hashed = FALSE);

  /**
   * Determines if the set identifier was prehashed.
   *
   * @return bool|null
   *   boolean if identifier has been set, otherwise NULL.
   */
  public function identifierIsPreHashed();

  /**
   * Gets list of avatar types provided by this API.
   *
   * @return string[]
   *   An array of type labels, keyed by type.
   */
  public static function getTypes();

  /**
   * Gets the avatar type.
   *
   * @return string
   *   Avatar type.
   */
  public function getType();

  /**
   * Sets the avatar type.
   *
   * @param string $type
   *   The avatar type.
   *
   * @throws \Drupal\avatars\Exception\AvatarException
   *   Thrown if this the type is not defined.
   *
   * @return \Drupal\avatars\AvatarBaseInterface
   *   Returns the called Robohash object for chaining.
   *
   * @see \Drupal\avatars\AvatarBaseInterface::getTypes()
   */
  public function setType($type);

  /**
   * Sets dimensions to get form the endpoint.
   *
   * @param int $width
   *   The width of the avatar.
   * @param int|null $height
   *   The height of the avatar, or NULL to mirror value for width.
   *
   * @throws \Drupal\avatars\Exception\AvatarException
   *   Thrown if the passed dimensions are invalid.
   *
   * @return \Drupal\avatars\AvatarBaseInterface
   *   Returns the called Robohash object for chaining.
   */
  public function setDimensions($width, $height = NULL);

  /**
   * Whether the URL will be secure.
   *
   * @return bool
   *   Whether the URL should be secure.
   */
  public function isSecure();

  /**
   * Sets the request to secure.
   *
   * @param bool $secure_request
   *   If the request should be secure.
   *
   * @throws \Drupal\avatars\Exception\AvatarException
   *   Thrown if API does not support the requested secure state.
   *
   * @return \Drupal\avatars\AvatarBaseInterface
   *   Returns the called Robohash object for chaining.
   */
  public function setIsSecure($secure_request = TRUE);

  /**
   * Prepare an identifier for transmission to a third party.
   *
   * @param string $identifier
   *   An identifier to obfuscate.
   *
   * @return string
   *   The obfuscated identifier.
   */
  public static function hashIdentifier($identifier);

  /**
   * Gets the URL for the avatar.
   *
   * @throws \Drupal\avatars\Exception\AvatarException
   *   Thrown if missing parameters.
   *
   * @return string
   *   A URL for an avatar.
   */
  public function getUrl();

}

Members

Namesort descending Modifiers Type Description Overrides
AvatarBaseInterface::getHostName public function Gets the request host name. 1
AvatarBaseInterface::getIdentifier public function Gets the identifier. 1
AvatarBaseInterface::getType public function Gets the avatar type. 1
AvatarBaseInterface::getTypes public static function Gets list of avatar types provided by this API. 3
AvatarBaseInterface::getUrl public function Gets the URL for the avatar. 3
AvatarBaseInterface::hashIdentifier public static function Prepare an identifier for transmission to a third party. 1
AvatarBaseInterface::identifierIsPreHashed public function Determines if the set identifier was prehashed. 1
AvatarBaseInterface::isSecure public function Whether the URL will be secure. 1
AvatarBaseInterface::setDimensions public function Sets dimensions to get form the endpoint. 1
AvatarBaseInterface::setHostName public function Sets the request host name. 1
AvatarBaseInterface::setIdentifier public function Sets a unique identifier to be passed to the API. 1
AvatarBaseInterface::setIsSecure public function Sets the request to secure. 1
AvatarBaseInterface::setType public function Sets the avatar type. 1