Wikibase
MediaWiki Wikibase extension
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)
 
 getSnakFormatter ( $format, FormatterOptions $options)
 Returns an SnakFormatter for rendering snaks in the desired format using the given options. More...
 

Private Member Functions

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

Private Attributes

 $snakFormatterConstructorCallbacks
 
 $valueFormatterFactory
 
 $propertyDataTypeLookup
 
 $dataTypeFactory
 

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 
)
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

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 (   $key,
  $languageCode 
)
private
Parameters
string$key
string$languageCode
Returns
Message

◆ 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

◆ $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: