24use Wikimedia\ObjectFactory;
57 $this->objectFactory = $objectFactory;
74 public function register( $name, $displayName, $spec ) {
75 if ( !is_callable( $spec ) ) {
76 if ( is_array( $spec ) ) {
77 if ( !isset( $spec[
'args'] ) ) {
84 throw new InvalidArgumentException(
'Invalid callback provided' );
87 $this->factoryFunctions[$name] = $spec;
88 $this->displayNames[$name] = $displayName;
98 return $this->displayNames;
108 if ( !isset( $this->factoryFunctions[$name] ) ) {
109 throw new SkinException(
"No registered builder available for $name." );
112 return $this->objectFactory->createObject(
113 $this->factoryFunctions[$name],
115 'allowCallable' =>
true,
116 'assertClass' => Skin::class,
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.
__construct(ObjectFactory $objectFactory)
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.