-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Feature Request: Support Embedded Entities with Both Shared and EmptyOnTranslate Properties
Description
Currently, the translation bundle does not fully handle embedded entities that contain a mix of properties marked with #[SharedAmongstTranslations] and #[EmptyOnTranslate].
In cases where an embeddable has some properties marked as shared and others marked to be emptied on translation, the current logic only partially applies the rules:
handleEmptyOnTranslateis not always invoked for embeddables that are not marked#[EmptyOnTranslate]at the top level.handleSharedAmongstTranslationsmay override or block emptying logic, resulting in incorrect translation behavior.
This limits the flexibility for entities with mixed attribute usage and can lead to inconsistent translation results.
Proposed Changes
- Ensure that embedded entities are always inspected recursively, regardless of top-level attributes.
- Apply
#[EmptyOnTranslate]rules to each property within an embedded object. - Apply
#[SharedAmongstTranslations]rules only afterEmptyOnTranslatelogic has been evaluated. - Return the correct instance based on the combination of both attributes (empty first, then shared).
Benefits
- Full support for mixed attribute usage in embedded entities.
- Consistent and predictable translation behavior.
- Increased flexibility for complex entity structures.
References
- Current implementation of
handleEmptyOnTranslateandhandleSharedAmongstTranslations. - Doctrine Embeddables: Doctrine ORM – Embedded Objects
Suggested Implementation Plan
- Update
EntityTranslatorto detect all embedded properties, even if the top-level embeddable does not have#[SharedAmongstTranslations]or#[EmptyOnTranslate]. - For each property within an embedded entity:
- Apply
handleEmptyOnTranslateif the property has the#[EmptyOnTranslate]attribute. - Apply
handleSharedAmongstTranslationsif the property has the#[SharedAmongstTranslations]attribute.
- Apply
- Combine results:
- Prefer
EmptyOnTranslatenullification first. - Apply
SharedAmongstTranslationslogic afterward.
- Prefer
- Ensure recursion works for nested embeddables, maintaining consistent behavior across all levels.
- Add comprehensive unit tests to cover mixed attribute scenarios.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request