webfactory / WebfactoryPolyglotBundle

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

Missing Translatable annotations: Reduce RuntimeException to log message? #14

Open MalteWunsch opened 2 years ago

MalteWunsch commented 2 years ago

The RuntimeException thrown in https://github.com/webfactory/WebfactoryPolyglotBundle/blob/f632d196a2639d38322ed2f05890a6fb58ca578a/src/Doctrine/TranslatableClassMetadata.php#L166 seem to harsh to me.

Sometimes I want to deploy some preparation for translations (namely the *Translatable entity and it's migration) early, so that the migration is executed in the production database and clients can start translating content, before the code is fully functioning. When I do the preparation lazily, I might add @Polyglot\Locale at the class level, but miss to @Polyglot\Translatable at the appripriate attributes - and don't think twice about it, as I know the code does not need to work right now. This results in the RuntimeException.

Having missed adding an annotation is nothing I would expect to result in a RuntimeException. If there are no appropriate tests, this might slip through into production.

Hence I think about reducing this RuntimeException to a log message. If I don't get a translation as expected, the logs might be one of the last places I would look at, but the entity attribute or the README instructions of this bundle seem to be reasonable as first points of contact, so this might be enough?

WDYT, @mpdude @FabianSchmick ?

FabianSchmick commented 2 years ago

I do understand your valid case and would also log the message instead of throwing an Exception. To hint this in the README should also be done as you mentioned.