You are here

protected function UserManager::setProfilePic in Social Auth 8.2

Same name and namespace in other branches
  1. 3.x src/User/UserManager.php \Drupal\social_auth\User\UserManager::setProfilePic()

Downloads and sets user profile picture.

Parameters

\Drupal\social_auth\User\SocialAuthUserInterface $user: The Social Auth User object.

Return value

bool True if picture was successfully set. False otherwise.

1 call to UserManager::setProfilePic()
UserManager::createNewUser in src/User/UserManager.php
Creates a new user.

File

src/User/UserManager.php, line 365

Class

UserManager
Manages database related tasks.

Namespace

Drupal\social_auth\User

Code

protected function setProfilePic(SocialAuthUserInterface $user) {
  $picture_url = $user
    ->getPictureUrl();
  $id = $user
    ->getProviderId();

  // Tries to download the profile picture and add it to Social Auth User.
  if ($this
    ->userPictureEnabled()) {
    $file = $this
      ->downloadProfilePic($picture_url, $id);
    if ($file) {
      $user
        ->setPicture($file
        ->id());
    }
  }
  return FALSE;
}