You are here

private function DrupalUserProcessor::provisionLdapEntryOnUserUpdateCreateEvent in Lightweight Directory Access Protocol (LDAP) 8.3

Handle the user update/create event with LDAP entry provisioning.

1 call to DrupalUserProcessor::provisionLdapEntryOnUserUpdateCreateEvent()
DrupalUserProcessor::drupalUserUpdated in ldap_user/src/Processor/DrupalUserProcessor.php
Callback for hook_ENTITY_TYPE_update().

File

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

Class

DrupalUserProcessor
Handles processing of a user from LDAP to Drupal.

Namespace

Drupal\ldap_user\Processor

Code

private function provisionLdapEntryOnUserUpdateCreateEvent() {
  if (SemaphoreStorage::get('provision', $this->account
    ->getAccountName()) || SemaphoreStorage::get('sync', $this->account
    ->getAccountName())) {
    return;
  }
  $processor = new LdapUserProcessor();

  // Check if provisioning to LDAP has already occurred this page load.
  if (!$processor
    ->getProvisionRelatedLdapEntry($this->account)) {
    $provisionResult = $processor
      ->provisionLdapEntry($this->account);
    if ($provisionResult['status'] == 'success') {
      SemaphoreStorage::set('provision', $this->account
        ->getAccountName());
    }
  }

  // Sync if not just provisioned and enabled.
  if (SemaphoreStorage::get('provision', $this->account
    ->getAccountName()) == FALSE) {

    // Check if provisioning to LDAP has already occurred this page load.
    if (LdapConfiguration::provisionAvailableToLdap(self::PROVISION_LDAP_ENTRY_ON_USER_ON_USER_UPDATE_CREATE) && $processor
      ->getProvisionRelatedLdapEntry($this->account)) {
      $ldapProcessor = new LdapUserProcessor();
      if ($ldapProcessor
        ->syncToLdapEntry($this->account)) {
        SemaphoreStorage::set('sync', $this->account
          ->getAccountName());
      }
    }
  }
}