Don't throw exception when entity lacks an ID

Created on 26 April 2024, 7 months ago

Problem/Motivation

I have a case when I want to postpone the save of entities after the enclosing form entity is saved. I have some good reasons for that, like I want to store a reverse reference in the IEF entity. I'm using a custom handler that just does nothing in the InlineFormInterface::save() method to avoid the IEF entity being saved in this stage. But ReferenceUpgrader::registerEntity() enforces a saved entity with ID.

Why?

I don't see any reason why this is enforced. If entities don't have IDs we should avoid registering and, later, the reference for those entities will not be created, allowing 3rd-party code (like mine) to deal with this.

Proposed resolution

Don't register entities with no ID.

Alternative solutions (but needlessly more complex!):

  • Make the enforcement configurable, so 3rd-party can opt-out
  • Make ReferenceUpgrader swappable (maybe convert to a service?)

Remaining tasks

None.

User interface changes

None.

API changes

More relaxed approach, allowing more for 3rd-party

Data model changes

None.

📌 Task
Status

Needs review

Version

3.0

Component

Code

Created by

🇷🇴Romania claudiu.cristea Arad 🇷🇴

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