webfactory / WebfactoryPolyglotBundle

Symfony bundle simplifying translations in Doctrine.
MIT License
3 stars 2 forks source link

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

Closed mpdude closed 6 months ago

mpdude commented 6 months ago

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.