webfactory / WebfactoryPolyglotBundle

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

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

Closed mpdude closed 10 months ago

mpdude commented 10 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.