Skip to content

Enhance entity creation with base field expansion and dynamic id key#271

Closed
chrisolof wants to merge 3 commits intojhedstrom:masterfrom
chrisolof:270-entity-creation-enhancements
Closed

Enhance entity creation with base field expansion and dynamic id key#271
chrisolof wants to merge 3 commits intojhedstrom:masterfrom
chrisolof:270-entity-creation-enhancements

Conversation

@chrisolof
Copy link
Copy Markdown
Contributor

@chrisolof chrisolof commented Mar 6, 2024

Resolves #270.

Pairs really well with jhedstrom/drupalextension/pull/661.

…nsion

Per FieldHandlerInterface::expand(), field handlers expect an array of
field values.  The source entity object passed into expandEntityFields()
often has an inconsistent structure across its various field properties,
sometimes holding a single value, sometimes holding an array of values (as
expected), and sometimes holding an array of composite field parts for a
single field value.  Consistently providing field handlers the field values
in the structure they expect allows them to expand each field value
correctly.

jhedstromgh-270
@AlexSkrypnyk
Copy link
Copy Markdown
Collaborator

Hey @chrisolof - thanks for this contribution! This is a significant refactor that consolidates entity creation into a unified flow. We're planning to tackle this as part of the v3.x effort (see #312) where we'll have kernel tests to properly validate the changes. I'll leave this open as reference for that work. Appreciate the thoughtful implementation!

@AlexSkrypnyk
Copy link
Copy Markdown
Collaborator

Hey @chrisolof - thanks for this contribution! Master has moved on significantly since this was opened (v3.x restructure, capability interfaces, kernel tests), so a clean rebase was not viable - but your insight absolutely was. I have opened #346 which reimplements the two bugs you identified against current master: auto-detection of base fields in expandEntityFields so commerce_product.variations and similar base entity-reference fields go through the handler pipeline, and dynamic id key resolution in entityCreate/entityDelete. Your original PR is attributed at the top of #346, and there is a dedicated kernel test covering the commerce_product to variations scenario you originally hit. I will close this PR once #346 lands. Appreciate you catching these!

@AlexSkrypnyk
Copy link
Copy Markdown
Collaborator

Landed via #346. Thanks again, @chrisolof!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Entity creation does not expand base fields & assumes "id" for entity ID key (D8/9/10 driver)

2 participants