public function SimpleLdapUserSync::updateDrupalUser in Simple LDAP 8
Dispatches an event so other modules can map LDAP properties.
Once all the subscribers have been processed, we determine if the Drupal user object changed. If that's the case we slate the user for saving, once.
Parameters
\Drupal\simple_ldap_user\SimpleLdapUser $user: The LDAP properties for this user.
\Drupal\user\UserInterface $account: The Drupal account object.
bool $force_save: Set to TRUE
1 call to SimpleLdapUserSync::updateDrupalUser()
- SimpleLdapUserSync::importIntoDrupal in modules/
simple_ldap_user/ src/ SimpleLdapUserSync.php - Imports the LDAP information into Drupal if necessary.
File
- modules/
simple_ldap_user/ src/ SimpleLdapUserSync.php, line 116
Class
Namespace
Drupal\simple_ldap_userCode
public function updateDrupalUser(SimpleLdapUser $user, UserInterface $account, $force_save = FALSE) {
static $scheduled_saves = [];
$uuid = $account
->uuid();
$save_happening = $force_save || !empty($scheduled_saves[$uuid]);
// Fire the synchronization event so other modules can map properties
// as needed.
$event = new SimpleLdapUserEvent($user, $account);
// If save is enforced we can safely skip serialization.
$hashed_pre = $save_happening ? '' : $this
->serialize($account);
$this->eventDispatcher
->dispatch(Events::USER_SYNCHRONIZATION, $event);
$hashed_post = $save_happening ? '' : $this
->serialize($account);
$has_changed = $hashed_pre !== $hashed_post;
if (empty($scheduled_saves[$uuid]) && ($has_changed || $force_save)) {
// Schedule saving til the end of the request. Only save once even if the
// event is dispatched multiple times.
drupal_register_shutdown_function([
$account,
'save',
]);
$scheduled_saves[$uuid] = TRUE;
}
}