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. | |
getFeatureBodyClass () | |
Return a list of classes that should be added to the body tag. | |
isFeatureEnabled (string $feature) | |
Gets whether the feature's requirements are met. | |
registerRequirement (Requirement $requirement) | |
Register a complex {. | |
registerSimpleRequirement (string $name, bool $isMet) | |
Register a {. | |
isRequirementMet (string $name) | |
Gets whether the requirement is met. | |
MediaWiki\Skins\Vector\FeatureManagement\FeatureManager::getFeatureBodyClass | ( | ) |
Return a list of classes that should be added to the body tag.
MediaWiki\Skins\Vector\FeatureManagement\FeatureManager::isFeatureEnabled | ( | string | $feature | ) |
Gets whether the feature's requirements are met.
string | $feature |
InvalidArgumentException If the feature isn't registered
MediaWiki\Skins\Vector\FeatureManagement\FeatureManager::isRequirementMet | ( | string | $name | ) |
Gets whether the requirement is met.
string | $name | The name of the requirement |
InvalidArgumentException If the requirement isn't registered
MediaWiki\Skins\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 |
LogicException If the feature is already registered
Wikimedia\Assert\ParameterAssertionException If the feature's requirements aren't the name of a single requirement or a list of requirements
InvalidArgumentException If the feature references a requirement that isn't registered
MediaWiki\Skins\Vector\FeatureManagement\FeatureManager::registerRequirement | ( | Requirement | $requirement | ) |
Register a complex {.
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 |
LogicException If the requirement has already been registered
MediaWiki\Skins\Vector\FeatureManagement\FeatureManager::registerSimpleRequirement | ( | string | $name, |
bool | $isMet ) |
Register a {.
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 |
LogicException If the requirement has already been registered