You are here

private function DrupalUserProcessor::setUserDefinedMappings in Lightweight Directory Access Protocol (LDAP) 8.4

Same name and namespace in other branches
  1. 8.3 ldap_user/src/Processor/DrupalUserProcessor.php \Drupal\ldap_user\Processor\DrupalUserProcessor::setUserDefinedMappings()

Sets the additional, user-defined fields.

The greyed out user mappings are not passed to this function.

Parameters

string $event: Provisioning event.

2 calls to DrupalUserProcessor::setUserDefinedMappings()
DrupalUserProcessor::applyAttributesToAccount in ldap_user/src/Processor/DrupalUserProcessor.php
Apply field values to user account.
DrupalUserProcessor::applyAttributesToAccountOnCreate in ldap_user/src/Processor/DrupalUserProcessor.php
Apply field values to user account.

File

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

Class

DrupalUserProcessor
Handles processing of a user from LDAP to Drupal.

Namespace

Drupal\ldap_user\Processor

Code

private function setUserDefinedMappings(string $event) : void {
  $mappings = $this->fieldProvider
    ->getConfigurableAttributesSyncedOnEvent($event);
  foreach ($mappings as $key => $mapping) {

    // If "convert from binary is selected" and no particular method is in
    // token default to binaryConversionToString() function.
    if ($mapping
      ->isBinary() && strpos($mapping
      ->getLdapAttribute(), ';') === FALSE) {
      $mapping
        ->setLdapAttribute(str_replace(']', ';binary]', $mapping
        ->getLdapAttribute()));
    }
    $value = $this->tokenProcessor
      ->ldapEntryReplacementsForDrupalAccount($this->ldapEntry, $mapping
      ->getLdapAttribute());

    // The ordinal $value_instance is not used and could probably be
    // removed.
    [
      $value_type,
      $value_name,
    ] = $this
      ->parseUserAttributeNames($key);
    if ($value_type === 'field' || $value_type === 'property') {
      $this->account
        ->set($value_name, $value === '' ? NULL : $value);
    }
  }
}