Vector
Vector is a skin for MediaWiki. Vector has been the default skin on all Wikimedia wikis since 2010.
|
Public Member Functions | |
registerFeature (string $feature, $requirements) | |
Register a feature and its requirements. More... | |
isFeatureEnabled (string $feature) | |
Gets whether the feature's requirements are met. More... | |
registerRequirement (Requirement $requirement) | |
Register a complex requirement. More... | |
registerSimpleRequirement (string $name, bool $isMet) | |
Register a requirement. More... | |
isRequirementMet (string $name) | |
Gets whether the requirement is met. More... | |
Vector\FeatureManagement\FeatureManager::isFeatureEnabled | ( | string | $feature | ) |
Gets whether the feature's requirements are met.
string | $feature |
Vector\FeatureManagement\FeatureManager::isRequirementMet | ( | string | $name | ) |
Gets whether the requirement is met.
string | $name | The name of the requirement |
Vector\FeatureManagement\FeatureManager::registerFeature | ( | string | $feature, |
$requirements | |||
) |
Register a feature and its requirements.
Essentially, a "feature" is a friendly (hopefully) name for some component, however big or small, that has some requirements. A feature manager allows us to decouple the component's logic from its requirements, allowing them to vary independently. Moreover, the use of friendly names wherever possible allows us to define a common language with our non-technical colleagues.
defines the "featureA" feature, which is enabled when the "requirementA" requirement is met.
defines the "featureB" feature, which is enabled when the "requirementA" and "requirementB" requirements are met. Note well that the feature is only enabled when all requirements are met, i.e. the requirements are evaluated in order and logically AND
ed together.
string | $feature | The name of the feature |
string | array | $requirements | The feature's requirements. As above, you can define a feature that requires a single requirement via the shorthand |
Vector\FeatureManagement\FeatureManager::registerRequirement | ( | Requirement | $requirement | ) |
Register a complex requirement.
A complex requirement is one that depends on object that may or may not be fully loaded while the application is booting, e.g. see User::isSafeToLoad
.
Such requirements are expected to be registered during a hook that is run early on in the application lifecycle, e.g. the BeforePerformAction
and APIBeforeMain
hooks.
Requirement | $requirement |
Vector\FeatureManagement\FeatureManager::registerSimpleRequirement | ( | string | $name, |
bool | $isMet | ||
) |
Register a requirement.
A requirement is some condition of the application state that a feature requires to be true or false.
string | $name | The name of the requirement |
bool | $isMet | Whether the requirement is met |