jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/403225 )
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. The parameters order goes as it
reads, first Feature, then Context
Bug: T182362
Change-Id: Ie320d84b63298d3daad9cd1c2325dd4d53639d11
---
M includes/features/FeaturesManager.php
M includes/features/IFeature.php
2 files changed, 24 insertions(+), 0 deletions(-)
Approvals:
jenkins-bot: Verified
Jdlrobson: Looks good to me, approved
diff --git a/includes/features/FeaturesManager.php
b/includes/features/FeaturesManager.php
index 2edecff..6b6b37c 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,15 @@
return $this->features[ $id ];
}
+ /**
+ * Verify that feature $featureId is available in $context
+ *
+ * @param string $featureId Feature id to verify
+ * @param MobileContext $context Mobile context to check
+ * @return bool
+ */
+ public function isFeatureAvailableInContext( $featureId, MobileContext
$context ) {
+ $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/403225
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie320d84b63298d3daad9cd1c2325dd4d53639d11
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: specialpages
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Pmiazga <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits