Skip to content
Snippets Groups Projects

Update the field type category for dynamic entity reference.

2 files
+ 20
28
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -732,29 +732,10 @@ class DynamicEntityReferenceItem extends EntityReferenceItem {
* {@inheritdoc}
*/
public static function getPreconfiguredOptions() {
$options = [];
// Add all the commonly referenced entity types as distinct pre-configured
// options.
$entity_types = \Drupal::entityTypeManager()->getDefinitions();
$common_references = array_filter($entity_types, function (EntityTypeInterface $entity_type) {
return $entity_type->isCommonReferenceTarget();
});
/** @var \Drupal\Core\Entity\EntityTypeInterface $entity_type */
foreach ($common_references as $entity_type) {
$options[$entity_type->id()] = [
'label' => $entity_type->getLabel(),
'field_storage_config' => [
'settings' => [
'exclude_entity_types' => FALSE,
'entity_type_ids' => [$entity_type->id()],
],
],
];
}
return $options;
// Override the default parent implementation, do not provide any
// preconfigured options, dynamic references commonly have multiple
// target types.
return [];
}
/**
Loading