webfactory / WebfactoryPolyglotBundle

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

Fix that `#[Polyglot\Translatable]` may be used on unmapped fields #68

Closed mpdude closed 3 months ago

mpdude commented 3 months ago

It may be useful to use the #[Polyglot\Translatable] attribute (or the corresponding annotation) on properties that are not configured as mapped Doctrine ORM fields. For example, the property value might be set by entity lifecycle callbacks or Doctrine listeners.

It was possible to do so until #28 changed \Webfactory\Bundle\PolyglotBundle\Doctrine\TranslatableClassMetadata::findTranslatedProperties to work based on Doctrine ORM ClassMetadata information and fields. This was done to simplify detection of whether a particular property belongs to a given class or needs to be mapped through base class translations. Obviously, ClassMetadata does not know about unmapped properties.

This PR changes the code to work on PHP reflection data instead, restoring functionality.