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

Dispatching snak formatter that makes it possible to special case certain Snaks based on the associated property's data type. More...

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

Public Member Functions

 __construct ( $format, PropertyDataTypeLookup $dataTypeLookup, SnakFormatter $specialCaseSnakFormatter, SnakFormatter $fallbackSnakFormatter, array $specialCasedPropertyDataTypes)
 
 formatSnak (Snak $snak)
 
 getFormat ()
 

Private Member Functions

 getSnakDataType (Snak $snak)
 

Private Attributes

 $format
 
 $dataTypeLookup
 
 $specialCaseSnakFormatter
 
 $fallbackSnakFormatter
 
 $specialCasedPropertyDataTypes
 

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

Dispatching snak formatter that makes it possible to special case certain Snaks based on the associated property's data type.

Depending on that data type, we choose between a "special" SnakFormatter and a generic one.

Author
Marius Hoch

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Lib\Formatters\BinaryOptionDispatchingSnakFormatter::__construct (   $format,
PropertyDataTypeLookup  $dataTypeLookup,
SnakFormatter  $specialCaseSnakFormatter,
SnakFormatter  $fallbackSnakFormatter,
array  $specialCasedPropertyDataTypes 
)
Parameters
string$formatOne of the SnakFormatter::FORMAT_... constants.
PropertyDataTypeLookup$dataTypeLookup
SnakFormatter$specialCaseSnakFormatterSnak formatter to use for Snaks with a property data type in $specialCasedPropertyDataTypes.
SnakFormatter$fallbackSnakFormatter
array$specialCasedPropertyDataTypes

Member Function Documentation

◆ formatSnak()

Wikibase\Lib\Formatters\BinaryOptionDispatchingSnakFormatter::formatSnak ( Snak  $snak)
See also
SnakFormatter::formatSnak
Parameters
Snak$snak
Exceptions
FormattingException
PropertyDataTypeLookupException
Returns
string The formatted snak value, in the format specified by getFormat().

Implements Wikibase\Lib\Formatters\SnakFormatter.

◆ getFormat()

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

Implements Wikibase\Lib\Formatters\SnakFormatter.

◆ getSnakDataType()

Wikibase\Lib\Formatters\BinaryOptionDispatchingSnakFormatter::getSnakDataType ( Snak  $snak)
private
Parameters
Snak$snak
Exceptions
PropertyDataTypeLookupException
Returns
string|null The Snak's data type

Member Data Documentation

◆ $dataTypeLookup

Wikibase\Lib\Formatters\BinaryOptionDispatchingSnakFormatter::$dataTypeLookup
private

◆ $fallbackSnakFormatter

Wikibase\Lib\Formatters\BinaryOptionDispatchingSnakFormatter::$fallbackSnakFormatter
private

◆ $format

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

◆ $specialCasedPropertyDataTypes

Wikibase\Lib\Formatters\BinaryOptionDispatchingSnakFormatter::$specialCasedPropertyDataTypes
private

◆ $specialCaseSnakFormatter

Wikibase\Lib\Formatters\BinaryOptionDispatchingSnakFormatter::$specialCaseSnakFormatter
private

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