Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 299521

ContentEntityBase::addTranslation() should not fire hook_entity_create()

$
0
0

Follow-up of #2382493: Population of default field values in entity translation is incorrect

Problem/Motivation

The current handling of default values in ContentEntityBase::addTranslation() feels very inefficient: it creates a new fresh entity that gets default values, only to be able to copy those values over to the new translation. Additionally hook_entity_create() is called when creating an entity translation which is incorrect.

Proposed resolution

  • Make sure ContentEntityStorageBase::doCreate($values) and ContentEntityBase::addTranslation($values) reuse the same code for the "merge default values into the passed in $values".
  • Introduce a new hook_entity_field_values_init() hook to allow to alter these values regardless of whether we are initializing a new entity or a new entity translation.
  • Introduce a new hook_entity_translation_create() hook to allow to react to entity translation creation.

Remaining tasks

  • Validate the proposed solution
  • Evaluate whether it can be committed during the RC phase
  • Reviews

User interface changes

None

API changes

Mostly additive:

  • ContentEntityStorageBase now implements a new ContentEntityStorageInterface.
  • ContentEntityBase::addTranslation() throws a logic exception if the entity storage handler does not implement ContentEntityStorageInterface.

Data model changes

None


Viewing all articles
Browse latest Browse all 299521

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>