wikimedia / ToolforgeBundle

A Symfony 4 & 5 bundle that provides some common parts of web-based tools running on Wikimedia's Toolforge. Maintained by the Wikimedia Foundation's Community Tech team.
https://packagist.org/packages/wikimedia/toolforge-bundle
GNU General Public License v3.0
13 stars 4 forks source link

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

Open MusikAnimal opened 5 years ago

MusikAnimal commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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.