public function LinkedFieldManager::getDestinationFields in Linked Field 8
Get allowed destination fields.
Parameters
string $entity_type_id: The entity type ID.
string $bundle_id: The bundle ID.
Return value
array An array containing the field names keyed by their machine name.
Overrides LinkedFieldManagerInterface::getDestinationFields
File
- src/
LinkedFieldManager.php, line 87
Class
- LinkedFieldManager
- Provides helper methods for client related functionalities.
Namespace
Drupal\linked_fieldCode
public function getDestinationFields($entity_type_id, $bundle_id) {
$field_names = [];
$fields = $this->entityFieldManager
->getFieldDefinitions($entity_type_id, $bundle_id);
$label_field = $this->entityTypeManager
->getDefinition($entity_type_id)
->getKey('label');
// Remove the label field from fields.
unset($fields[$label_field]);
foreach ($fields as $field_name => $field) {
if (in_array($field
->getType(), [
'link',
'string',
'list_float',
'list_string',
])) {
$field_names[$field_name] = $field
->getLabel() . ' (' . $field_name . ')';
}
}
return $field_names;
}