private function FieldProvider::loadUserDefinedMappings in Lightweight Directory Access Protocol (LDAP) 8.4
Load user-defined mappings from database configuration.
1 call to FieldProvider::loadUserDefinedMappings()
- FieldProvider::loadAttributes in ldap_user/
src/ FieldProvider.php - LDAP attributes to alter.
File
- ldap_user/
src/ FieldProvider.php, line 141
Class
- FieldProvider
- Provides the basic and required fields needed for user mappings.
Namespace
Drupal\ldap_userCode
private function loadUserDefinedMappings() : void {
$database_mappings = $this->config
->get('ldapUserSyncMappings');
// Leave early if there are no user mappings.
if (!isset($database_mappings[$this->direction]) || empty($database_mappings[$this->direction])) {
return;
}
foreach ($database_mappings[$this->direction] as $id => $mapping) {
if (isset($this->attributes[$mapping['user_attr']])) {
$label = $this->attributes[$mapping['user_attr']]
->getLabel();
}
$prepared_mapping = new Mapping($id, $label ?? $id, TRUE, TRUE, $mapping['prov_events'], $mapping['config_module'], $mapping['prov_module']);
$prepared_mapping
->setDrupalAttribute($mapping['user_attr']);
$prepared_mapping
->setLdapAttribute($mapping['ldap_attr']);
$prepared_mapping
->setUserTokens($mapping['user_tokens']);
if ($mapping['convert']) {
$prepared_mapping
->convertBinary($mapping['convert']);
}
// This is an unideal solution to the mappings being keyed on name.
// @todo Replace with a plain array in the configuration storage.
$key = $this->direction === self::PROVISION_TO_DRUPAL ? $mapping['user_attr'] : $mapping['ldap_attr'];
$this->attributes[$key] = $prepared_mapping;
}
}