You are here

private function DrupalUserProcessor::parseUserAttributeNames 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::parseUserAttributeNames()

Parse user attribute names.

Parameters

string $user_attribute_key: A string in the form of <attr_type>.<attr_name>[:<instance>] such as field.lname, property.mail, field.aliases:2.

Return value

array An array such as [field, 'field_user_lname'].

1 call to DrupalUserProcessor::parseUserAttributeNames()
DrupalUserProcessor::setUserDefinedMappings in ldap_user/src/Processor/DrupalUserProcessor.php
Sets the additional, user-defined fields.

File

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

Class

DrupalUserProcessor
Handles processing of a user from LDAP to Drupal.

Namespace

Drupal\ldap_user\Processor

Code

private function parseUserAttributeNames(string $user_attribute_key) : array {
  $type = '';
  $name = '';

  // Make sure no [] are on attribute.
  $user_attribute_key = trim($user_attribute_key, '[]');
  $parts = explode('.', $user_attribute_key);
  if ($parts !== FALSE) {
    $type = $parts[0];
    $name = $parts[1] ?? '';
    if ($name) {

      // Remove everything after the colon (could be simplified).
      $name_parts = explode(':', $name);
      if ($name_parts !== FALSE && isset($name_parts[1])) {
        $name = $name_parts[0];
      }
    }
  }
  return [
    $type,
    $name,
  ];
}