You are here

class SocialAuthUser in Social Auth 3.x

Same name and namespace in other branches
  1. 8.2 src/User/SocialAuthUser.php \Drupal\social_auth\User\SocialAuthUser

User data used for authentication with Drupal.

Hierarchy

Expanded class hierarchy of SocialAuthUser

File

src/User/SocialAuthUser.php, line 8

Namespace

Drupal\social_auth\User
View source
class SocialAuthUser implements SocialAuthUserInterface {

  /**
   * First name.
   *
   * @var string|null
   */
  protected $firstName;

  /**
   * Last name.
   *
   * @var string|null
   */
  protected $lastName;

  /**
   * Used to create the username in Drupal: first + last most of the time.
   *
   * @var string
   */
  protected $name;

  /**
   * Email address.
   *
   * @var string|null
   */
  protected $email;

  /**
   * ID in provider.
   *
   * @var string
   */
  protected $providerUserID;

  /**
   * Token used for authentication in provider.
   *
   * @var string|mixed
   */
  protected $token;

  /**
   * URL to get profile picture.
   *
   * @var string
   */
  protected $pictureUrl = NULL;

  /**
   * Profile picture file.
   *
   * @var string|int|null
   */
  protected $picture = NULL;

  /**
   * User's extra data. Store in additional_data field in social_auth entity.
   *
   * @var array|null
   */
  protected $additionalData;

  /**
   * Other data added through external modules (e.g. event subscribers)
   *
   * @var array
   */
  protected $customData;

  /**
   * User constructor.
   *
   * @param string $name
   *   The user's name.
   * @param string $email
   *   The user's email address.
   * @param string $provider_user_id
   *   The unique ID in provider.
   * @param string $token
   *   The access token for making API calls.
   * @param string|bool $picture_url
   *   The user's picture.
   * @param array|null $additional_data
   *   The additional user data to be stored in database.
   */
  public function __construct($name, $email, $provider_user_id, $token, $picture_url = NULL, $additional_data = NULL) {
    $this->name = $name;
    $this->email = $email;
    $this->providerUserID = $provider_user_id;
    $this->token = $token;
    $this->pictureUrl = $picture_url;
    $this->additionalData = $additional_data;
  }

  /**
   * {@inheritdoc}
   */
  public function getFirstName() {
    return $this->firstName;
  }

  /**
   * {@inheritdoc}
   */
  public function setFirstName($first_name) {
    $this->firstName = $first_name;
  }

  /**
   * {@inheritdoc}
   */
  public function getLastName() {
    return $this->lastName;
  }

  /**
   * {@inheritdoc}
   */
  public function setLastName($last_name) {
    $this->lastName = $last_name;
  }

  /**
   * {@inheritdoc}
   */
  public function getName() {
    return $this->name;
  }

  /**
   * {@inheritdoc}
   */
  public function setName($name) {
    $this->name = $name;
  }

  /**
   * {@inheritdoc}
   */
  public function getEmail() {
    return $this->email;
  }

  /**
   * {@inheritdoc}
   */
  public function setEmail($email) {
    $this->email = $email;
  }

  /**
   * {@inheritdoc}
   */
  public function getProviderId() {
    return $this->providerUserID;
  }

  /**
   * {@inheritdoc}
   */
  public function setProviderId($provider_id) {
    $this->providerUserID = $provider_id;
  }

  /**
   * {@inheritdoc}
   */
  public function getToken() {
    return $this->token;
  }

  /**
   * {@inheritdoc}
   */
  public function setToken($token) {
    $this->token = $token;
  }

  /**
   * {@inheritdoc}
   */
  public function getPictureUrl() {
    return $this->pictureUrl;
  }

  /**
   * {@inheritdoc}
   */
  public function setPictureUrl($picture_url) {
    $this->pictureUrl = $picture_url;
  }

  /**
   * {@inheritdoc}
   */
  public function getPicture() {
    return $this->picture;
  }

  /**
   * {@inheritdoc}
   */
  public function setPicture($file_id) {
    $this->picture = $file_id;
  }

  /**
   * {@inheritdoc}
   */
  public function getAdditionalData() {
    return $this->additionalData;
  }

  /**
   * {@inheritdoc}
   */
  public function setAdditionalData($additional_data) {
    $this->additionalData = $additional_data;
  }

  /**
   * {@inheritdoc}
   */
  public function addData($key, $value) {
    $this->customData[$key] = $value;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getData($key) {
    return $this->customData[$key] ?? NULL;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SocialAuthUser::$additionalData protected property User's extra data. Store in additional_data field in social_auth entity.
SocialAuthUser::$customData protected property Other data added through external modules (e.g. event subscribers)
SocialAuthUser::$email protected property Email address.
SocialAuthUser::$firstName protected property First name.
SocialAuthUser::$lastName protected property Last name.
SocialAuthUser::$name protected property Used to create the username in Drupal: first + last most of the time.
SocialAuthUser::$picture protected property Profile picture file.
SocialAuthUser::$pictureUrl protected property URL to get profile picture.
SocialAuthUser::$providerUserID protected property ID in provider.
SocialAuthUser::$token protected property Token used for authentication in provider.
SocialAuthUser::addData public function Adds a new key-value pair in customData. Overrides SocialAuthUserInterface::addData
SocialAuthUser::getAdditionalData public function Set the user's additional data. Overrides SocialAuthUserInterface::getAdditionalData
SocialAuthUser::getData public function Gets a value from customData. Overrides SocialAuthUserInterface::getData
SocialAuthUser::getEmail public function Gets the user's email. Overrides SocialAuthUserInterface::getEmail
SocialAuthUser::getFirstName public function Gets the user's first name. Overrides SocialAuthUserInterface::getFirstName
SocialAuthUser::getLastName public function Gets the user's last name. Overrides SocialAuthUserInterface::getLastName
SocialAuthUser::getName public function Gets the user's name. Overrides SocialAuthUserInterface::getName
SocialAuthUser::getPicture public function Gets the user's picture ID. Overrides SocialAuthUserInterface::getPicture
SocialAuthUser::getPictureUrl public function Gets the user's picture URL. Overrides SocialAuthUserInterface::getPictureUrl
SocialAuthUser::getProviderId public function Gets the user's id in provider. Overrides SocialAuthUserInterface::getProviderId
SocialAuthUser::getToken public function Gets the user's token. Overrides SocialAuthUserInterface::getToken
SocialAuthUser::setAdditionalData public function Sets the user's additional data. Overrides SocialAuthUserInterface::setAdditionalData
SocialAuthUser::setEmail public function Sets the user's email. Overrides SocialAuthUserInterface::setEmail
SocialAuthUser::setFirstName public function Sets the user's first name. Overrides SocialAuthUserInterface::setFirstName
SocialAuthUser::setLastName public function Sets the user's last name. Overrides SocialAuthUserInterface::setLastName
SocialAuthUser::setName public function Sets the user's name. Overrides SocialAuthUserInterface::setName
SocialAuthUser::setPicture public function Sets the user's picture ID. Overrides SocialAuthUserInterface::setPicture
SocialAuthUser::setPictureUrl public function Sets the user's picture URL. Overrides SocialAuthUserInterface::setPictureUrl
SocialAuthUser::setProviderId public function Sets the user's id in provider. Overrides SocialAuthUserInterface::setProviderId
SocialAuthUser::setToken public function Sets the user's token. Overrides SocialAuthUserInterface::setToken
SocialAuthUser::__construct public function User constructor.