You are here

public function LdapTestFunctions::prepConsumerConf in Lightweight Directory Access Protocol (LDAP) 7.2

Same name and namespace in other branches
  1. 8.2 ldap_test/LdapTestFunctions.class.php \LdapTestFunctions::prepConsumerConf()
  2. 7 ldap_servers/tests/LdapTestFunctions.class.php \LdapTestFunctions::prepConsumerConf()

File

ldap_test/LdapTestFunctions.class.php, line 117

Class

LdapTestFunctions

Code

public function prepConsumerConf($consumer_confs) {

  // Create consumer authorization configuration.
  foreach ($consumer_confs as $consumer_type => $consumer_conf) {
    $consumer_obj = ldap_authorization_get_consumer_object($consumer_type);
    $consumer_conf_admin = new LdapAuthorizationConsumerConfAdmin($consumer_obj, TRUE);
    foreach ($consumer_conf as $property_name => $property_value) {
      $consumer_conf_admin->{$property_name} = $property_value;
    }
    foreach ($consumer_conf_admin->mappings as $i => $mapping) {
      $mappings = $consumer_obj
        ->normalizeMappings([
        [
          $mapping['from'],
          $mapping['user_entered'],
        ],
      ], FALSE);
      $consumer_conf_admin->mappings[$i] = $mappings[0];
    }
    $consumer_conf_admin
      ->save();
  }
}