Skip to content
Snippets Groups Projects

Add workaround support for dynamic_entity_reference fields

Merged Jan Hug requested to merge 3441330-workaround-support-for-dyanmic_entity_reference into 1.0.x
1 file
+ 15
0
Compare changes
  • Side-by-side
  • Inline
@@ -277,6 +277,9 @@ class EntitySchemaBuilder {
// this field at all.
return NULL;
}
elseif ($fieldType === 'dynamic_entity_reference') {
return $field->type('Entity');
}
elseif ($typedData instanceof TextWithSummaryItem) {
$summary = $this->createField('summary')->type('Boolean');
return $field->type('String')->argument($summary);
@@ -312,6 +315,15 @@ class EntitySchemaBuilder {
*/
private function getTypeForEntityReferenceFieldItem(FieldItemDataDefinitionInterface $itemDefinition): ?string {
$targetType = $itemDefinition->getSetting('target_type');
$dataType = $itemDefinition->getDataType();
// Special handling for the "dynamic_entity_reference" contrib module that
// allows referencing multiple different entity types in a field.
// Because we don't (yet) support union types, we just type these fields
// using the generic Entity interface.
if ($dataType === 'field_item:dynamic_entity_reference') {
return 'Entity';
}
// Check if the target entity type is enabled.
if (!$targetType || !$this->config->isEntityTypeEnabled($targetType)) {
@@ -868,6 +880,9 @@ class EntitySchemaBuilder {
case 'config_dependencies':
return 'MapData';
case 'dynamic_entity_reference':
return 'Entity';
case '_core_config_info':
return NULL;
Loading