Skip to content

IBX-11959: Added message template accessors to Translation value objects - #795

Open
tbialcz wants to merge 1 commit into
6.0from
IBX-11959-add-translation-getters
Open

IBX-11959: Added message template accessors to Translation value objects#795
tbialcz wants to merge 1 commit into
6.0from
IBX-11959-add-translation-getters

Conversation

@tbialcz

@tbialcz tbialcz commented Jul 31, 2026

Copy link
Copy Markdown
Contributor
🎫 Issue IBX-11959

Description:

Added a shared contract to the Translation base class: getMessageTemplate() + getValues(), implemented by Message and Plural. Consumers no longer need to distinguish the two or rely on magic ValueObject::__get property access.

Needed by the follow-up ibexa/user PR for IBX-11959 (ibexa/user#132). No behavior change.

For QA:

No user-facing change, covered by unit tests. End-to-end QA on the ibexa/user PR.

Documentation:

For 6.0.0 release notes: new abstract methods getMessageTemplate() and getValues() on Ibexa\Contracts\Core\Repository\Values\Translation — third-party subclasses must implement them.

@alongosz alongosz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For QA
Internal API only

src/contracts/FieldType/ValidationError.php is definitely not an internal API. Though it doesn't mean that there's something to QA. It's rather something for Doc release notes of 6.0.0

Comment on lines +23 to +25
* @return \Ibexa\Contracts\Core\Repository\Values\Translation\Message|\Ibexa\Contracts\Core\Repository\Values\Translation\Plural
*/
public function getTranslatableMessage(): Translation;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a code smell to me. We're declaring it as strict Translation but then say that we return some other types and in each impl. we define Translation again and say again that it's something else.

Can't covariance/contravariance or templating be used here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switched to a native Message|Plural return type on the contract, implementations covariantly narrow to Message. Docblocks removed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it me or this is much worse, why other Translation interfaces implementation cannont be returned now from this method?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you couldn't really return anything else anyway, Translation has only __toString() so everyone checks for Message or Plural to do their job. Subclassing Message/Plural still works

Comment thread tests/lib/Repository/Values/Translation/MessageTest.php Outdated
@tbialcz tbialcz added the Doc needed The changes require some documentation label Jul 31, 2026
@tbialcz
tbialcz requested a review from alongosz July 31, 2026 12:08
@tbialcz
tbialcz force-pushed the IBX-11959-add-translation-getters branch from f9fa1f4 to 27baa0d Compare August 3, 2026 11:20
@tbialcz tbialcz changed the title IBX-11959: Added getters to Translation Message and Plural value objects IBX-11959: Added message template accessors to Translation value objects Aug 3, 2026
@tbialcz
tbialcz requested review from Steveb-p and konradoboza August 3, 2026 11:21
Comment thread src/contracts/Repository/Values/Translation.php Outdated
@tbialcz
tbialcz force-pushed the IBX-11959-add-translation-getters branch from 27baa0d to dc6195e Compare August 3, 2026 11:50
@sonarqubecloud

sonarqubecloud Bot commented Aug 3, 2026

Copy link
Copy Markdown

@Steveb-p Steveb-p left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mnocon mnocon removed the Doc needed The changes require some documentation label Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants