core
core copied to clipboard
[Users] Move or remove any additional processing from UsersModule Profile and Messages twig extensions
So we have Profile and Message twig extensions we can use and these are provided by UsersModule
userAvatar
profileLinkByUserId
profileLinkByUserName
etc...
These twig extensions at the end are calling additional modules 3rd party that provide actual content. The problem is that hmm... if I want to create, a profile module that is complex and will provide complex and custom profile link - with js ajax CSS and much more, should I be able to do that?
At the moment Users module collects only plain url from ProfileModule and then add it's own HTML and stuff which is not overridable, customizable... shouldn't we use above twig calls as a proxy without additional markup?
I guess it is due to BC but let's be honest if we have only one twig method available like profileLinkByUserId
and it does not even allow you to get plain url without additional markup something is wrong...
I'm making those issues with the intention to fix them. I do have a plan and a few solutions are already coded - as soon as I will test them properly and will have a time I will do commit.
Do you have specific suggestions/proposals? I think the primary step is deciding how to change or extend the module interfaces. The Twig functions are only bringing this into the templates in a second step.
Hmm... need to look at it as it was long time ago when I wrote this issue... I'm not sure about module interfaces... actually apart from return string declaration...
Ok so what does it mean getProfileUrl or getAvatar in ProfileModuleInterface?
Because now it returns just raw data, string, but could return piece of html an component, like fully composed profile url with tooltip or popover with all sorts of informations and features - example avatars and profile links here on github - just hover on your name. Then mentioned twig extension only displays it in template.
It should only act as a proxy and pass params to a selected module (ProfileModule in this case) and let ProfileModule handle everything.
For BC we could extend those interfaces to utilise additional $dataOnly parameter which means it works the way it works now.
Below profile link creation function should be inside profile module not in users module. https://github.com/zikula/core/blob/master/src/system/UsersModule/Twig/Extension/ProfileExtension.php#L153-L179
This way profile module could be equipped with few of those "profile link" designs... default one could be chosen in settings while other via params...
Both profile link filters should work same way as avatar function. No additional processing only straight call to a selected profile module.
Extraction basically done in 68245a430 but still subject to change. Closing for now.