Page MenuHomePhabricator

Developer: Allow easier access to AMC user modes
Closed, ResolvedPublic

Description

It should be pretty easy to retrieve the single user mode to verify is it enabled by user. The current implementation required developer to retrieve the user mode by getting service from MediaWikiServices (which required to know the full service name). In the long run it would cause trouble. Developers should have easy access to the information they often need.

Now, instead of retrieving UserMode from MediaWikiServices, or trying to initialize the mode once again just to get the mode identifier developer can do:

$featureManager->getMode( 'amc' )->isEnabled();

The featureManager will be available in most places where mobile features come into play. If feature manager is not currently available, the second approach is to retrieve UserModes service
which will know all registered services, and it will allow to get single service (or for example it can return all modes enabled by user).

Below an example, how to check the user amc user mode without having the featureManager initialized.

MediaWikiServices::getInstance()
  ->getService( 'MobileFrontend.UserModes' )
  ->getMode( 'amc' )
  ->isEnabled();

Thanks to that, user will have to know only one service, and this service will provide access to all registered user modes.

Event Timeline

Jdlrobson renamed this task from Allow easier access to AMC user modes to Developer: Allow easier access to AMC user modes.Mar 18 2019, 11:25 PM

Change 489317 had a related patch set uploaded (by Jdlrobson; owner: Pmiazga):
[mediawiki/extensions/MobileFrontend@master] Hygiene: allow easier access to user modes

https://gerrit.wikimedia.org/r/489317

@pmiazga I created this task so that your patch doesn't get lost and to provide a place we can discuss it/track it outside Gerrit.

Change 489317 had a related patch set uploaded (by Pmiazga; owner: Pmiazga):
[mediawiki/extensions/MobileFrontend@master] Hygiene: allow easier access to user modes

https://gerrit.wikimedia.org/r/489317

Change 489317 merged by jenkins-bot:
[mediawiki/extensions/MobileFrontend@master] Hygiene: allow easier access to user modes

https://gerrit.wikimedia.org/r/489317

This task is merged, I think we can resolve it. If you have any questions please re-open the task @Jdlrobson