MediaWiki  master
SkinFactory Class Reference

Factory class to create Skin objects. More...

Collaboration diagram for SkinFactory:

Public Member Functions

 __construct (ObjectFactory $objectFactory, array $skipSkins)
 
 getAllowedSkins ()
 Fetch the list of user-selectable skins in regards to $wgSkipSkins. More...
 
 getInstalledSkins ()
 Fetch the list of all installed skins. More...
 
 getSkinNames ()
 Returns an associative array of: skin name => human readable name. More...
 
 getSkinOptions (string $name)
 Return options provided for a given skin name. More...
 
 makeSkin ( $name)
 Create a given Skin using the registered callback for $name. More...
 
 register ( $name, $displayName, $spec, $skippable=false)
 Register a new Skin factory function. More...
 

Private Attributes

array $displayNames = []
 Map of name => fallback human-readable name, used when the 'skinname-<skin>' message is not available. More...
 
array< string, array|callable > $factoryFunctions = []
 Map of skin name to object factory spec or factory function. More...
 
ObjectFactory $objectFactory
 
string[] $skipSkins
 Array of skins that should not be presented in the list of available skins in user preferences, while they're still installed. More...
 

Detailed Description

Factory class to create Skin objects.

Since
1.24

Definition at line 31 of file SkinFactory.php.

Constructor & Destructor Documentation

◆ __construct()

SkinFactory::__construct ( ObjectFactory  $objectFactory,
array  $skipSkins 
)
Access: internal
For ServiceWiring only
Parameters
ObjectFactory$objectFactory
string[]$skipSkins

Definition at line 65 of file SkinFactory.php.

References $objectFactory, and $skipSkins.

Member Function Documentation

◆ getAllowedSkins()

SkinFactory::getAllowedSkins ( )

Fetch the list of user-selectable skins in regards to $wgSkipSkins.

Useful for Special:Preferences and other places where you only want to show skins users can select from preferences page.

Returns
string[]
Since
1.36

Definition at line 145 of file SkinFactory.php.

References getInstalledSkins().

◆ getInstalledSkins()

SkinFactory::getInstalledSkins ( )

Fetch the list of all installed skins.

Returns an associative array of skin name => human readable name

Returns
string[]
Since
1.37

Definition at line 163 of file SkinFactory.php.

References $displayNames.

Referenced by getAllowedSkins().

◆ getSkinNames()

SkinFactory::getSkinNames ( )

Returns an associative array of: skin name => human readable name.

Deprecated:
since 1.37 use getInstalledSkins instead
Returns
array

Definition at line 113 of file SkinFactory.php.

References $displayNames.

◆ getSkinOptions()

SkinFactory::getSkinOptions ( string  $name)

Return options provided for a given skin name.

Since
1.38
Parameters
string$nameName of the skin you want options from
Returns
array Skin options passed into constructor

Definition at line 174 of file SkinFactory.php.

References makeSkin().

◆ makeSkin()

SkinFactory::makeSkin (   $name)

Create a given Skin using the registered callback for $name.

Parameters
string$nameName of the skin you want
Exceptions
SkinExceptionIf a factory function isn't registered for $name
Returns
Skin

Definition at line 123 of file SkinFactory.php.

Referenced by getSkinOptions().

◆ register()

SkinFactory::register (   $name,
  $displayName,
  $spec,
  $skippable = false 
)

Register a new Skin factory function.

Will override if it's already registered.

Parameters
string$nameInternal skin name. Should be all-lowercase (technically doesn't have to be, but doing so would change the case of i18n message keys).
string$displayNameFor backwards-compatibility with old skin loading system. This is the text used as skin's human-readable name when the 'skinname-<skin>' message is not available.
array | callable$specCallback that takes the skin name as an argument, or object factory spec specifying how to create the skin
bool$skippablewhether the skin is skippable and should be hidden in preferences.
Exceptions
InvalidArgumentExceptionIf an invalid callback is provided

Definition at line 86 of file SkinFactory.php.

Member Data Documentation

◆ $displayNames

array SkinFactory::$displayNames = []
private

Map of name => fallback human-readable name, used when the 'skinname-<skin>' message is not available.

Definition at line 45 of file SkinFactory.php.

Referenced by getInstalledSkins(), and getSkinNames().

◆ $factoryFunctions

array<string,array|callable> SkinFactory::$factoryFunctions = []
private

Map of skin name to object factory spec or factory function.

Definition at line 38 of file SkinFactory.php.

◆ $objectFactory

ObjectFactory SkinFactory::$objectFactory
private

Definition at line 49 of file SkinFactory.php.

Referenced by __construct().

◆ $skipSkins

string [] SkinFactory::$skipSkins
private

Array of skins that should not be presented in the list of available skins in user preferences, while they're still installed.

Definition at line 57 of file SkinFactory.php.

Referenced by __construct().


The documentation for this class was generated from the following file: