Pmiazga has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/403221 )
Change subject: Hygiene: Introduce a isFeatureAvailableInContext() method ...................................................................... Hygiene: Introduce a isFeatureAvailableInContext() method Sometimes we want to check the feature availabilti in given context. Insted of replicating same logic in different extensions lets provide a helper function to detect the BETA mode first and then check the feature availability. Bug: T182362 Change-Id: Ie320d84b63298d3daad9cd1c2325dd4d53639d11 --- M includes/features/FeaturesManager.php M includes/features/IFeature.php 2 files changed, 23 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/21/403221/1 diff --git a/includes/features/FeaturesManager.php b/includes/features/FeaturesManager.php index 2edecff..77ef6fb 100644 --- a/includes/features/FeaturesManager.php +++ b/includes/features/FeaturesManager.php @@ -2,6 +2,8 @@ namespace MobileFrontend\Features; +use MobileContext; + class FeaturesManager { /** * A collection of available features @@ -43,4 +45,14 @@ return $this->features[ $id ]; } + /** + * Verify that feature $featureId is available in $context + * @param MobileContext $context Mobile context to check + * @param string $featureId Feature id to verify + * @return bool + */ + public function isFeatureAvailableInContext( MobileContext $context, $featureId ) { + $mode = $context->isBetaGroupMember() ? IFeature::CONFIG_BETA : IFeature::CONFIG_STABLE; + return $this->getFeature( $featureId )->isAvailable( $mode ); + } } diff --git a/includes/features/IFeature.php b/includes/features/IFeature.php index 6122541..1efae64 100644 --- a/includes/features/IFeature.php +++ b/includes/features/IFeature.php @@ -4,6 +4,17 @@ interface IFeature { /** + * Beta mode defined in config + * @var string + */ + const CONFIG_BETA = 'beta'; + /** + * Stable mode defined in config + * @var string + */ + const CONFIG_STABLE = 'base'; + + /** * Get the feature id * Used as a identifier in forms, database etc. Should be unique * -- To view, visit https://gerrit.wikimedia.org/r/403221 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie320d84b63298d3daad9cd1c2325dd4d53639d11 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Pmiazga <pmia...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits