Topic on Manual talk:User preferences

How to inject a different Preferences object?

1
Samwilson (talkcontribs)

I'm working on Extension:GlobalPreferences and trying to figure out how best to do things with the all preferences, after they've been defined (in order to show various extra Preferences-form bits and pieces). At the moment, we're using $wgExtensionFunctions and hacking the $wgHooks global to add a new callback at the end of $wgHooks['GetPreferences'].

One idea is to add a new MediaWiki service called 'PreferencesFactory', that can be used to retrieve a new Preferences object. Extensions would then be able to use the MediaWikiServices hook to redefine the PreferencesFactory (with MediaWikiServices::redefineService()). Of course, only one extension would be able to do that (which maybe is a bit odd?).

Apart from being able to override the Preferences class, a service for this would also mean the Preferences class could be refactored (gradually?) to not be such a collection of static methods.

The proposed patch is: https://gerrit.wikimedia.org/r/#/c/374451/

I'd love to hear anyone's ideas about this, including completely different and better ways to do things. :-)

Reply to "How to inject a different Preferences object?"