Skip to content

Add class-level #[TranslatedProperty] configuration option#89

Merged
mpdude merged 4 commits intomasterfrom
class-level-attributes
Mar 18, 2026
Merged

Add class-level #[TranslatedProperty] configuration option#89
mpdude merged 4 commits intomasterfrom
class-level-attributes

Conversation

@mpdude
Copy link
Member

@mpdude mpdude commented Mar 18, 2026

This PR introduces a new #[Polyglot\TranslatedProperty('propertyName')] PHP attribute that can be placed at the class level to declare the translatable properties.

This is a useful alternative to placing #[Polyglot\Translatable] directly on the property in the case of Doctrine ORM mapped superclasses: Base classes (potentially provided by other libraries) can be extended, and it is left to the extending code to add Polyglot support, without touching the superclass and without re-defining properties (which is not possible with Doctrine ORM).

See the EntityInheritance_MappedSuperclass fixture class added here for an example. Note, however, that this class needs to use a union type including TranslatableInterface (or no property type at all) to allow subclasses to make fields translatable.

@mpdude mpdude merged commit 1273914 into master Mar 18, 2026
8 checks passed
@mpdude mpdude deleted the class-level-attributes branch March 18, 2026 19:52
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