Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move i18n-related Twig helpers to Wikimedia\ToolforgeBundle\Service\Intuition #25

Open
MusikAnimal opened this issue Jun 20, 2019 · 2 comments

Comments

@MusikAnimal
Copy link
Member

MusikAnimal commented Jun 20, 2019

All the nifty i18n-related helpers in Twig\Extension could be moved to Wikimedia\ToolforgeBundle\Service\Intuition. This way I can for instance use msgIfExists() in my PHP code. The Twig helpers can instead simply call the methods in Service\Intuition.

Also, I'm not sure how Wikimedia\ToolforgeBundle\Service\Intuition works, but it would seem I can't type-hint it and use the Krinkle\Intuition methods, even though it extends Krinkle\Intuition. Maybe it's not registered as a public service?

This is the one barrier keeping XTools from using ToolforgeBundle. See i18nHelper for it's implementation (basically verbatim the same as ToolforgeBundle's Twig\Extension, except in a public service).

@samwilson
Copy link
Member

Sounds good to me.

Do you mean that the Twig functions & filters would still be defined in Wikimedia\ToolforgeBundle\Twig\Extension but that they'd just be wrappers for methods in Wikimedia\ToolforgeBundle\Service\Intuition?

Oh oops yeah that's what you wrote. :) I should read before typing.

What bit is not working for type-hinting with the Intuition class? It seems to be working fine for me.

@MusikAnimal
Copy link
Member Author

What bit is not working for type-hinting with the Intuition class? It seems to be working fine for me.

XTools' Twig extension type-hints the i18nHelper. I simply changed this to type-hint ToolforgeBundle\Service\Intuition and got the "no such service exists" error. It does know about Krinkle\Intuition, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants
@samwilson @MusikAnimal and others