public static function ConvertNodes::getToFields in Convert Nodes 8
1 call to ConvertNodes::getToFields()
- ConvertNodesForm::buildForm in src/
Form/ ConvertNodesForm.php - Form constructor.
File
- src/
ConvertNodes.php, line 59
Class
- ConvertNodes
- ConvertNodes.
Namespace
Drupal\convert_nodesCode
public static function getToFields($fields_to) {
$fields_to_names = [];
$fields_to_types = [];
// Add some extra options for the form.
$fields_to_names['remove'] = 'remove';
$fields_to_names['append_to_body'] = 'append_to_body';
// Get the to fields in an array.
foreach ($fields_to as $field) {
if ($field
->getFieldStorageDefinition()
->isBaseField() == FALSE) {
// Because might be target_id.
$val_name = $field
->getFieldStorageDefinition()
->getMainPropertyName();
// Because some data types are more complex.
$data_type = '';
$type = $field
->getType();
if (empty($field
->getFieldStorageDefinition()
->getPropertyDefinition($val_name))) {
$data_type = $type;
}
else {
$data_type = $field
->getFieldStorageDefinition()
->getPropertyDefinition($val_name)
->getDataType();
}
$fields_to_names[$field
->getName()] = '[' . $field
->getName() . '] ' . (is_object($field
->getLabel()) ? $field
->getLabel()
->render() : $field
->getLabel());
$fields_to_types[$field
->getName()] = $data_type;
}
}
return [
'fields_to_names' => $fields_to_names,
'fields_to_types' => $fields_to_types,
];
}