Wikibase
MediaWiki Wikibase extension
Wikibase\Lib\Formatters\SnakFormat Class Reference

Helper for handling SnakFormatter output formats. More...

Public Member Functions

 getFallbackFormat ( $format)
 Get the format to fallback to, in case a given format is not available. More...
 
 getFallbackChain ( $format)
 Get the fallback chain for a given format. More...
 
 getBaseFormat ( $format)
 Get the base output format, for a given format. More...
 
 isPossibleFormat ( $availableFormat, $targetFormat)
 Can the given target format be served by the available format. More...
 

Detailed Description

Helper for handling SnakFormatter output formats.

Author
Daniel Kinzler
Marius Hoch

Member Function Documentation

◆ getBaseFormat()

Wikibase\Lib\Formatters\SnakFormat::getBaseFormat (   $format)

Get the base output format, for a given format.

Parameters
string$format
Returns
string One of the SnakFormatter::FORMAT_HTML/FORMAT_WIKI/FORMAT_PLAIN constants.

◆ getFallbackChain()

Wikibase\Lib\Formatters\SnakFormat::getFallbackChain (   $format)

Get the fallback chain for a given format.

The returned array contains the SnakFormatter::FORMAT_* constants to use, from best fitting to worst.

Parameters
string$formatEither of the SnakFormatter::FORMAT_* constants.
Returns
string[] SnakFormatter::FORMAT_* constants, starting with the most preferred format

◆ getFallbackFormat()

Wikibase\Lib\Formatters\SnakFormat::getFallbackFormat (   $format)

Get the format to fallback to, in case a given format is not available.

Parameters
string$formatOne of the SnakFormatter::FORMAT_... constants.
Exceptions
InvalidArgumentException
Returns
string One of the SnakFormatter::FORMAT_* constants.

◆ isPossibleFormat()

Wikibase\Lib\Formatters\SnakFormat::isPossibleFormat (   $availableFormat,
  $targetFormat 
)

Can the given target format be served by the available format.

Parameters
string$availableFormat
string$targetFormat
Returns
bool Whether $availableFormat can be served by $targetFormat.

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