24use Wikimedia\ObjectFactory;
65 public function __construct( ObjectFactory $objectFactory, array $skipSkins ) {
66 $this->objectFactory = $objectFactory;
67 $this->skipSkins = $skipSkins;
84 public function register( $name, $displayName, $spec ) {
85 if ( !is_callable( $spec ) ) {
86 if ( is_array( $spec ) ) {
87 if ( !isset( $spec[
'args'] ) ) {
94 throw new InvalidArgumentException(
'Invalid callback provided' );
97 $this->factoryFunctions[$name] = $spec;
98 $this->displayNames[$name] = $displayName;
108 return $this->displayNames;
118 if ( !isset( $this->factoryFunctions[$name] ) ) {
119 throw new SkinException(
"No registered builder available for $name." );
122 return $this->objectFactory->createObject(
123 $this->factoryFunctions[$name],
125 'allowCallable' =>
true,
126 'assertClass' => Skin::class,
143 unset( $allowedSkins[
'fallback'] );
144 unset( $allowedSkins[
'apioutput'] );
146 foreach ( $this->skipSkins as $skip ) {
147 unset( $allowedSkins[$skip] );
150 return $allowedSkins;
Exceptions for skin-related failures.
Factory class to create Skin objects.
array< string, array|callable > $factoryFunctions
Map of skin name to object factory spec or factory function.
makeSkin( $name)
Create a given Skin using the registered callback for $name.
array $displayNames
Map of name => fallback human-readable name, used when the 'skinname-<skin>' message is not available...
ObjectFactory $objectFactory
getSkinNames()
Returns an associative array of: skin name => human readable name.
getAllowedSkins()
Fetch the list of user-selectable skins in regards to $wgSkipSkins.
string[] $skipSkins
Array of skins that should not be presented in the list of available skins in user preferences,...
__construct(ObjectFactory $objectFactory, array $skipSkins)