EntityReferenceItem should support a virtual `target_uuid` property

Created on 26 June 2025, 9 days ago

Problem/Motivation

It is possible for recipes to ship default content for Experience Builder. That default content can contain references to files/images, as entity references to media. But those references are buried in Experience Builder's input data structures, and although those references are powered by entity reference fields, they are encoded in such a way that our default content importer will not know how to handle them (we don't support denormalization on import).

Proposed resolution

It is an unfortunate deficiency that entity reference field items cannot refer to an entity by UUID. I understand that we store the serial integer (or string) target_id for, presumably, database efficiency reasons -- and that makes sense. But it would greatly improve the ability to use default content -- and unblock site template functionality -- if entity reference items had a virtual target_uuid property:

// Internally looks up the media item with that UUID and sets the `target_id` property accordingly.
$node->field_hero_image->target_uuid = 'abcdef-123456';

// Loads the entity from its `target_id` property and returns its UUID.
echo $node->field_hero_image->target_uuid;

For simplicity of implementation, the target_id should not be stored -- the data layer remains exactly the same.

User interface changes

None.

Introduced terminology

None.

API changes

All entity reference items will receive a new virtual property.

Data model changes

Not really.

Release notes snippet

TBD.

✨ Feature request
Status

Active

Version

11.0 πŸ”₯

Component

recipe system

Created by

πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024