You are here

function social_sso_social_auth_extra_profile_presave in Open Social 8

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_sso/social_sso.module \social_sso_social_auth_extra_profile_presave()
  2. 8.2 modules/social_features/social_sso/social_sso.module \social_sso_social_auth_extra_profile_presave()
  3. 8.3 modules/social_features/social_sso/social_sso.module \social_sso_social_auth_extra_profile_presave()
  4. 8.4 modules/social_features/social_sso/social_sso.module \social_sso_social_auth_extra_profile_presave()
  5. 8.5 modules/social_features/social_sso/social_sso.module \social_sso_social_auth_extra_profile_presave()
  6. 8.6 modules/social_features/social_sso/social_sso.module \social_sso_social_auth_extra_profile_presave()
  7. 8.7 modules/social_features/social_sso/social_sso.module \social_sso_social_auth_extra_profile_presave()
  8. 8.8 modules/social_features/social_sso/social_sso.module \social_sso_social_auth_extra_profile_presave()

Implements hook_social_auth_extra_profile_presave().

File

modules/social_features/social_sso/social_sso.module, line 16
Module file for Social SSO.

Code

function social_sso_social_auth_extra_profile_presave(UserInterface $account, ProfileInterface $profile, AuthManagerInterface $auth_manager, UserManagerInterface $user_manager) {
  $profile
    ->get('field_profile_first_name')
    ->setValue($auth_manager
    ->getFirstName());
  $profile
    ->get('field_profile_last_name')
    ->setValue($auth_manager
    ->getLastName());
  $entity_field_manager = \Drupal::service('entity_field.manager');
  $field_definitions = $entity_field_manager
    ->getFieldDefinitions('profile', 'profile');
  if (isset($field_definitions['field_profile_image'])) {
    $auth_manager
      ->setFieldPicture($field_definitions['field_profile_image']);
    $user_manager
      ->setFieldPicture($field_definitions['field_profile_image']);
    if ($url = $auth_manager
      ->getProfilePicture()) {
      $user_manager
        ->setProfilePicture($url, $user_manager
        ->getAccountId());
    }
  }
}