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

PropertyValueSnakFormatter is a formatter for PropertyValueSnaks. More...

+ Inheritance diagram for Wikibase\Lib\Formatters\PropertyValueSnakFormatter:
+ Collaboration diagram for Wikibase\Lib\Formatters\PropertyValueSnakFormatter:

Public Member Functions

 __construct ( $format, ValueFormatter $valueFormatter, PropertyDataTypeLookup $typeLookup, DataTypeFactory $dataTypeFactory)
 
 formatSnak (Snak $snak)
 
 getFormat ()
 

Private Member Functions

 getDataValueTypeForPropertyDataType ( $dataTypeId)
 Returns the expected value type for the given property data type.
 
 formatValue (DataValue $value, $dataTypeId)
 Calls the TypedValueFormatter passed to the constructor.
 

Private Attributes

 $format
 
 $valueFormatter
 
 $typeLookup
 
 $dataTypeFactory
 

Additional Inherited Members

- Public Attributes inherited from Wikibase\Lib\Formatters\SnakFormatter
const OPT_LANG = ValueFormatter::OPT_LANG
 Options key for controlling the output language.
 
const FORMAT_PLAIN = 'text/plain'
 Output format types.
 
const FORMAT_WIKI = 'text/x-wiki'
 
const FORMAT_HTML = 'text/html'
 
const FORMAT_HTML_DIFF = 'text/html; disposition=diff'
 
const FORMAT_HTML_VERBOSE = 'text/html; disposition=verbose'
 
const FORMAT_HTML_VERBOSE_PREVIEW = 'text/html; disposition=verbose-preview'
 
const OPT_ON_ERROR = 'on-error'
 Options key for controlling error handling.
 
const ON_ERROR_WARN = 'warn'
 Value for the OPT_ON_ERROR option indicating that recoverable errors should cause a warning to be show to the user.
 
const ON_ERROR_FAIL = 'fail'
 Value for the OPT_ON_ERROR option indicating that recoverable errors should cause the formatting to fail with an exception.
 

Detailed Description

PropertyValueSnakFormatter is a formatter for PropertyValueSnaks.

This is essentially a SnakFormatter adapter for TypedValueFormatter.

Author
Daniel Kinzler

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Lib\Formatters\PropertyValueSnakFormatter::__construct ( $format,
ValueFormatter $valueFormatter,
PropertyDataTypeLookup $typeLookup,
DataTypeFactory $dataTypeFactory )
Parameters
string$formatThe name of this formatter's output format. Use the FORMAT_XXX constants defined in SnakFormatter.
ValueFormatter$valueFormatter
PropertyDataTypeLookup$typeLookup
DataTypeFactory$dataTypeFactory
Exceptions
InvalidArgumentException

Member Function Documentation

◆ formatSnak()

Wikibase\Lib\Formatters\PropertyValueSnakFormatter::formatSnak ( Snak $snak)
See also
SnakFormatter::formatSnak

Formats the given Snak by looking up its property type and calling the ValueFormatter supplied to the constructor.

Parameters
Snak$snak
Exceptions
PropertyDataTypeLookupException
InvalidArgumentException
MismatchingDataValueTypeException
FormattingException
Returns
string Either plain text, wikitext or HTML, depending on the ValueFormatter provided.

Implements Wikibase\Lib\Formatters\SnakFormatter.

◆ formatValue()

Wikibase\Lib\Formatters\PropertyValueSnakFormatter::formatValue ( DataValue $value,
$dataTypeId )
private

Calls the TypedValueFormatter passed to the constructor.

Parameters
DataValue$value
string$dataTypeId
Exceptions
FormattingException
Returns
string Either plain text, wikitext or HTML, depending on the ValueFormatter provided.

◆ getDataValueTypeForPropertyDataType()

Wikibase\Lib\Formatters\PropertyValueSnakFormatter::getDataValueTypeForPropertyDataType ( $dataTypeId)
private

Returns the expected value type for the given property data type.

Parameters
string$dataTypeIdA property data type id
Returns
string A value type

◆ getFormat()

Wikibase\Lib\Formatters\PropertyValueSnakFormatter::getFormat ( )
See also
SnakFormatter::getFormat
Returns
string One of the SnakFormatter::FORMAT_... constants.

Implements Wikibase\Lib\Formatters\SnakFormatter.

Member Data Documentation

◆ $dataTypeFactory

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

◆ $format

Wikibase\Lib\Formatters\PropertyValueSnakFormatter::$format
private

◆ $typeLookup

Wikibase\Lib\Formatters\PropertyValueSnakFormatter::$typeLookup
private

◆ $valueFormatter

Wikibase\Lib\Formatters\PropertyValueSnakFormatter::$valueFormatter
private

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