Problem/Motivation

It's not possible for code that works with references to discover reference fields in an extensible fashion.

Code has to hardcode the name of reference field types, e.g. 'entity_reference' (in core), 'entity_reference_revisions', 'dynamic_entity_reference' (in contrib).

#3057545: ResourceTypeRepository wrongly assumes that all entity reference fields have the setting "target_type" adds an EntityReferenceItemInterface which would allow calling a field to get the referenceable types instead of hacking into field settings.

But it would also be useful to add an annotation property to field types so field type plugins can declare themselves as a reference field.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

joachim created an issue. See original summary.

bradjones1’s picture

Thought: ER fields should mark the id property as reserved, since json:api uses that pseudo-property for relationship resolution in FieldResolver.

bradjones1’s picture

Also, we must enforce the presence and type of the entity property, as Drupal core (e.g., json:api) requires that ER fields be settable by passing a loaded entity.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.