janrain_capture_mapping.module in Janrain Registration 8
Janrain Capture Mapping module file.
File
janrain_capture_mapping/janrain_capture_mapping.moduleView source
<?php
/**
* @file
* Janrain Capture Mapping module file.
*/
use Drupal\janrain_capture\User\JanrainUserProfile;
use Drupal\user\UserInterface;
use Drupal\Core\Utility\Error;
/**
* Implements hook_janrain_capture_user_authenticated().
*/
function janrain_capture_mapping_janrain_capture_user_authenticated(JanrainUserProfile $profile, UserInterface $user, bool $is_new) : void {
$profile_uuid = $profile
->getUuid();
$data = \Drupal::service('config.typed')
->get('janrain_capture.mapping')
->getValue();
if (isset($data['mapping']) && $user
->uuid() === $profile_uuid) {
foreach ($data['mapping'] as $mapping) {
try {
$user
->set($mapping['field'], $profile->{$mapping['capture_field']});
} catch (Exception $e) {
watchdog_exception('update', $e);
}
}
$user
->save();
}
}
Functions
Name | Description |
---|---|
janrain_capture_mapping_janrain_capture_user_authenticated | Implements hook_janrain_capture_user_authenticated(). |