Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Lib\Formatters\OutputFormatSnakFormatterFactory Class Reference

Factory service for obtaining a SnakFormatter for a desired output format. More...

Public Member Functions

 __construct (array $snakFormatterConstructorCallbacks, OutputFormatValueFormatterFactory $valueFormatterFactory, PropertyDataTypeLookup $propertyDataTypeLookup, DataTypeFactory $dataTypeFactory, MessageInLanguageProvider $messageInLanguageProvider)
 
 getSnakFormatter ( $format, FormatterOptions $options)
 Returns an SnakFormatter for rendering snaks in the desired format using the given options.
 

Private Member Functions

 getMessage (string $key, string $languageCode)
 
 createSnakFormatters ( $format, FormatterOptions $options)
 Instantiate SnakFormatters based on the constructor callbacks passed to the constructor.
 

Private Attributes

 $snakFormatterConstructorCallbacks
 
 $valueFormatterFactory
 
 $propertyDataTypeLookup
 
 $dataTypeFactory
 
 $messageInLanguageProvider
 

Detailed Description

Factory service for obtaining a SnakFormatter for a desired output format.

Implemented based on constructor callbacks and a default SnakFormatter implementation that uses TypedValueFormatters.

Author
Daniel Kinzler

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Lib\Formatters\OutputFormatSnakFormatterFactory::__construct ( array $snakFormatterConstructorCallbacks,
OutputFormatValueFormatterFactory $valueFormatterFactory,
PropertyDataTypeLookup $propertyDataTypeLookup,
DataTypeFactory $dataTypeFactory,
MessageInLanguageProvider $messageInLanguageProvider )
Parameters
callable[]$snakFormatterConstructorCallbacksAn associative array mapping property data type IDs to callbacks. The callbacks will be invoked with two parameters: the desired output format, and the FormatterOptions. Each callback must return an instance of SnakFormatter.
OutputFormatValueFormatterFactory$valueFormatterFactory
PropertyDataTypeLookup$propertyDataTypeLookup
DataTypeFactory$dataTypeFactory
MessageInLanguageProvider$messageInLanguageProvider

Member Function Documentation

◆ createSnakFormatters()

Wikibase\Lib\Formatters\OutputFormatSnakFormatterFactory::createSnakFormatters ( $format,
FormatterOptions $options )
private

Instantiate SnakFormatters based on the constructor callbacks passed to the constructor.

Parameters
string$format
FormatterOptions$options
Returns
SnakFormatter[]

◆ getMessage()

Wikibase\Lib\Formatters\OutputFormatSnakFormatterFactory::getMessage ( string $key,
string $languageCode )
private

◆ getSnakFormatter()

Wikibase\Lib\Formatters\OutputFormatSnakFormatterFactory::getSnakFormatter ( $format,
FormatterOptions $options )

Returns an SnakFormatter for rendering snaks in the desired format using the given options.

Parameters
string$formatUse the SnakFormatter::FORMAT_XXX constants.
FormatterOptions$options
Exceptions
RuntimeException
InvalidArgumentException
Returns
SnakFormatter

Member Data Documentation

◆ $dataTypeFactory

Wikibase\Lib\Formatters\OutputFormatSnakFormatterFactory::$dataTypeFactory
private

◆ $messageInLanguageProvider

Wikibase\Lib\Formatters\OutputFormatSnakFormatterFactory::$messageInLanguageProvider
private

◆ $propertyDataTypeLookup

Wikibase\Lib\Formatters\OutputFormatSnakFormatterFactory::$propertyDataTypeLookup
private

◆ $snakFormatterConstructorCallbacks

Wikibase\Lib\Formatters\OutputFormatSnakFormatterFactory::$snakFormatterConstructorCallbacks
private

◆ $valueFormatterFactory

Wikibase\Lib\Formatters\OutputFormatSnakFormatterFactory::$valueFormatterFactory
private

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