You are here

public function DrupalUserProcessor::drupalUserUpdated in Lightweight Directory Access Protocol (LDAP) 8.3

Callback for hook_ENTITY_TYPE_update().

Parameters

\Drupal\user\UserInterface $account: The Drupal user.

File

ldap_user/src/Processor/DrupalUserProcessor.php, line 539

Class

DrupalUserProcessor
Handles processing of a user from LDAP to Drupal.

Namespace

Drupal\ldap_user\Processor

Code

public function drupalUserUpdated(UserInterface $account) {

  // For some reason cloning was only necessary on the update hook.
  $this->account = clone $account;
  if (ExternalAuthenticationHelper::excludeUser($this->account)) {
    return;
  }

  // Check for provisioning to LDAP; this will normally occur on
  // hook_user_insert or other event when Drupal user is created.
  if ($this
    ->provisionsLdapEntriesFromDrupalUsers() && LdapConfiguration::provisionAvailableToLdap(self::PROVISION_LDAP_ENTRY_ON_USER_ON_USER_UPDATE_CREATE)) {
    $this
      ->provisionLdapEntryOnUserUpdateCreateEvent();
  }
  if (SemaphoreStorage::get('sync_drupal', $this->account
    ->getAccountName())) {
    return;
  }
  else {
    SemaphoreStorage::set('sync_drupal', $this->account
      ->getAccountName());
    if (LdapConfiguration::provisionsDrupalAccountsFromLdap() && in_array(self::EVENT_SYNC_TO_DRUPAL_USER, array_keys(LdapConfiguration::provisionsDrupalEvents()))) {
      $this
        ->syncToDrupalAccount(self::EVENT_SYNC_TO_DRUPAL_USER);
    }
  }
}