protected function LdapUserMappingToDrupalForm::getMappingRow in Lightweight Directory Access Protocol (LDAP) 8.4
Get mapping form row to LDAP user provisioning mapping admin form table.
Parameters
\Drupal\ldap_servers\Mapping $mapping: Is current setting for updates or non-configurable items.
array $target_fields: Attributes of Drupal user target options.
int $row_id: Only needed for LDAP.
Return value
array Row.
Overrides LdapUserMappingBaseForm::getMappingRow
File
- ldap_user/
src/ Form/ LdapUserMappingToDrupalForm.php, line 160
Class
- LdapUserMappingToDrupalForm
- Provides the form to configure user configuration and field mapping.
Namespace
Drupal\ldap_user\FormCode
protected function getMappingRow(Mapping $mapping, array $target_fields, int $row_id) : array {
$result = [];
if ($mapping
->isConfigurable()) {
$result['source'] = [
'#type' => 'textfield',
'#title' => 'LDAP attribute',
'#title_display' => 'invisible',
'#default_value' => $mapping
->getLdapAttribute(),
'#size' => 20,
'#maxlength' => 255,
'#attributes' => [
'class' => [
'ldap-attr',
],
],
];
$result['convert'] = [
'#type' => 'checkbox',
'#title' => 'Convert from binary',
'#title_display' => 'invisible',
'#default_value' => $mapping
->isBinary(),
'#attributes' => [
'class' => [
'convert',
],
],
];
$result['target'] = [
'#type' => 'select',
'#title' => 'User attribute',
'#title_display' => 'invisible',
'#default_value' => $mapping
->getDrupalAttribute(),
'#options' => $target_fields,
];
}
else {
$result['source'] = [
'#type' => 'item',
'#default_value' => $mapping
->getLdapAttribute(),
'#markup' => $mapping
->getLdapAttribute(),
'#attributes' => [
'class' => [
'source',
],
],
];
$result['convert'] = [
'#type' => 'checkbox',
'#title' => 'Convert from binary',
'#title_display' => 'invisible',
'#default_value' => $mapping
->isBinary(),
'#disabled' => TRUE,
'#attributes' => [
'class' => [
'convert',
],
],
];
$result['target'] = [
'#type' => 'item',
'#markup' => $mapping
->getLabel(),
];
}
foreach ($this->events as $event) {
$result[$event] = [
'#type' => 'checkbox',
'#title' => $event,
'#title_display' => 'invisible',
'#default_value' => $mapping
->hasProvisioningEvent($event),
'#disabled' => !$mapping
->isConfigurable(),
'#attributes' => [
'class' => [
'sync-method',
],
],
];
}
$result['delete'] = [
'#type' => 'checkbox',
'#default_value' => 0,
'#disabled' => !$mapping
->isConfigurable(),
];
$result['configured_mapping'] = [
'#type' => 'value',
'#value' => $mapping
->isConfigurable(),
];
return $result;
}