private function AdminSettingsForm::buildUdfMappingsForm in Acquia Lift Connector 8.3
Same name and namespace in other branches
- 8.4 src/Form/AdminSettingsForm.php \Drupal\acquia_lift\Form\AdminSettingsForm::buildUdfMappingsForm()
Build UDF mappings form.
Parameters
string $type: The type of UDF field. Can be person, touch or event.
Return value
array UDF mappings form.
Throws
Exception An exception if the type given is not supported.
1 call to AdminSettingsForm::buildUdfMappingsForm()
- AdminSettingsForm::buildForm in src/
Form/ AdminSettingsForm.php - Form constructor.
File
- src/
Form/ AdminSettingsForm.php, line 302
Class
- AdminSettingsForm
- Defines a form that configures settings.
Namespace
Drupal\acquia_lift\FormCode
private function buildUdfMappingsForm($type = 'person') {
if ($type !== 'person' && $type !== 'touch' && $type !== 'event') {
throw new Exception('This Udf Field type is not supported');
}
$field_mappings_settings = $this
->config('acquia_lift.settings')
->get('udf_' . $type . '_mappings');
$field_names = $this
->getTaxonomyTermFieldNames();
$udf_limit = SettingsHelper::getUdfLimitsForType($type);
$form = [
'#title' => $this
->t('User @type Mappings', [
'@type' => ucfirst($type),
]),
'#description' => $this
->t('Map taxonomy terms to Visitor Profile @type fields in Acquia Lift. Select a Taxonomy Reference Field that, if present, will map the value of the specified field to the Acquia Lift Profile for that specific visitor. No options available? Create <a href="@url" target="_blank">Taxonomy vocabularies</a> and map the corresponding value.', [
'@url' => Url::fromRoute('entity.taxonomy_vocabulary.collection')
->toString(),
'@type' => $type,
]),
'#type' => 'details',
'#tree' => TRUE,
'#group' => 'data_collection_settings',
];
// Go over the amount of fields that we can map.
for ($i = 1; $i < $udf_limit + 1; $i++) {
$form[$type . '_udf' . $i] = [
'#type' => 'select',
'#title' => $this
->t('User Profile @type Field @number', [
'@number' => $i,
'@type' => ucfirst($type),
]),
'#empty_value' => '',
'#options' => $field_names,
'#default_value' => isset($field_mappings_settings[$type . '_udf' . $i]['value']) ? $field_mappings_settings[$type . '_udf' . $i]['value'] : '',
];
}
return $form;
}