You are here

protected function LdapUserMappingBaseForm::loadAvailableMappings in Lightweight Directory Access Protocol (LDAP) 8.4

Derive synchronization mappings from configuration.

Parameters

string $direction: Direction.

string $sid: Server ID.

Return value

array Mappings.

1 call to LdapUserMappingBaseForm::loadAvailableMappings()
LdapUserMappingBaseForm::getServerMappingFields in ldap_user/src/Form/LdapUserMappingBaseForm.php
Return the server mappings for the fields.

File

ldap_user/src/Form/LdapUserMappingBaseForm.php, line 156

Class

LdapUserMappingBaseForm
Provides the form to configure user configuration and field mapping.

Namespace

Drupal\ldap_user\Form

Code

protected function loadAvailableMappings(string $direction, string $sid) : array {
  $attributes = [];
  if ($sid) {
    try {

      /** @var \Drupal\ldap_servers\Entity\Server $ldap_server */
      $ldap_server = $this->entityTypeManager
        ->getStorage('ldap_server')
        ->load($sid);
      $attributes = $this->fieldProvider
        ->loadAttributes($direction, $ldap_server);
    } catch (\Exception $e) {
      $this
        ->logger('ldap_user')
        ->error('Missing server');
    }
  }
  $params = [
    $direction,
    $sid,
  ];
  $this->moduleHandler
    ->alter('ldap_user_attributes', $attributes, $params);
  return $attributes;
}