Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test that Translatables can be used for values beyond strings, e. g. objects #30

Merged
merged 2 commits into from
Jan 9, 2024

Conversation

mpdude
Copy link
Member

@mpdude mpdude commented Jan 9, 2024

To avoid side effects during Doctrine ORM PHP-value-to-database-value conversion, this PR in part reverts design changes from #28:

On the preFlush event, remove all PersistentTranslatable instances from managed entities and replace them with their plain (primary) values. On postFlush, but the PersistentTranslatables back in place.

That way, the default (plain) values are in place when the ORM does its change detection.

Previously, in fact PersistentTranslatables were casted to string when the ORM gathered the values to insert into the database. That does not work when the column type is object, since it would try to serialize the PersistentTranslatable itself.

mpdude added 2 commits January 9, 2024 11:58
…n preFlush, and re-inject them in postFlush

This way we can be sure to get the default Doctrine change tracking and column conversion logic. This allows us to use e. g. object type columns as well.

When the change detection runs, no PersistentTranslatable proxies are in the way.
@mpdude mpdude changed the base branch from master to 3.x January 9, 2024 11:52
@mpdude mpdude changed the title support generic objects Test that Translatables can in fact be used for values beyond strings, e. g. objects Jan 9, 2024
@mpdude mpdude changed the title Test that Translatables can in fact be used for values beyond strings, e. g. objects Test that Translatables can be used for values beyond strings, e. g. objects Jan 9, 2024
@mpdude mpdude merged commit f7b186f into 3.x Jan 9, 2024
6 checks passed
@mpdude mpdude deleted the support-generic-objects branch January 9, 2024 12:00
This was referenced Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant