mediawiki-skins-Vector/includes/FeatureManagement/TODO.md
Sam Smith 3f95820467 featureManager: Set -> Requirement
As was noted in https://phabricator.wikimedia.org/T244481#5859513, the
term "set" doesn't seem natural. Piotr Miazga (polishdeveloper, pmiazga)
and Nicholas Ray (nray) suggested a number of good replacements,
including "requirement." Serendipitously, this term is already used in
FeatureManager's documentation.

Bug: T244481
Change-Id: I559c2d4149db69235cdd4bb880697deb1a145743
2020-03-06 17:23:46 +00:00

1.3 KiB

TODO

Currently the FeatureManager class is a very shallow interpretation of Piotr Miazga's proposed API and associated scaffolding classes (see https://phabricator.wikimedia.org/T244481 and https://gerrit.wikimedia.org/r/#/c/mediawiki/skins/Vector/+/572323/). This document aims to list the steps required to get from this system to something as powerful as Piotr's.

  1. Decide whether "set" is the correct name
  2. Add support for sets that utilise contextual information that isn't available at boot time, e.g.
use Vector\Constants;
use IContextSource;

$featureManager->registerRequirement( Constants::LOGGED_IN_REQ, function( IContextSource $context ) {
	$user = $context->getUser();

	return $user
		&& $user->isSafeToLoad()
		&& $user->isLoggedIn();
} );

$featureManager->registerRequirement( Constants::MAINSPACE_REQ, function ( IContextSource $context ) {
	$title = $context->getTitle();

	return $title && $title->inNamespace( NS_MAIN );
} );
  1. Consider supporing memoization of those requirements (see https://gerrit.wikimedia.org/r/#/c/mediawiki/skins/Vector/+/573626/7/includes/FeatureManagement/FeatureManager.php@68)
  2. Add support for getting all requirements
  3. Add support for getting all features enabled when a requirement is enabled/disabled