public static function ConvertBundles::sortUserInput in Convert Bundles 8
1 call to ConvertBundles::sortUserInput()
File
- src/
ConvertBundles.php, line 122
Class
- ConvertBundles
- ConvertBundles.
Namespace
Drupal\convert_bundlesCode
public static function sortUserInput($userInput, $fields_new_to, $fields_from) {
// Get user input and set up vars.
$map_fields = [];
$update_fields = [];
// Remove stuff we don't need.
$unset_data = [
'op',
'form_build_id',
'form_token',
'form_id',
];
foreach ($userInput as $from => $to) {
if (in_array($from, $unset_data)) {
continue;
}
if ($from == $to) {
$update_fields[] = $from;
}
elseif (in_array($from, $fields_new_to) && in_array($from, $userInput)) {
$map_fields['create_new'][] = [
'field' => $from,
'value' => $to,
];
}
else {
foreach ($fields_from as $field_def) {
if (isset($field_def[$from])) {
$map_fields[$from] = [
'field' => $to,
'from_label' => $field_def[$from]
->getLabel(),
// This will come in later.
'value' => [],
];
}
}
}
}
return [
'map_fields' => $map_fields,
'update_fields' => $update_fields,
];
}