DispatchingSnakFormatter will format a Snak by delegating the formatting to an appropriate SnakFormatter based on the snak type or the associated property's data type.
More...
|
| __construct (string $format, PropertyDataTypeLookup $dataTypeLookup, array $formattersBySnakType, array $formattersByDataType) |
|
| formatSnak (Snak $snak) |
|
| getFormat () |
|
DispatchingSnakFormatter will format a Snak by delegating the formatting to an appropriate SnakFormatter based on the snak type or the associated property's data type.
- Copyright
- GPL-2.0-or-later
- Author
- Daniel Kinzler
◆ __construct()
Wikibase\Lib\Formatters\DispatchingSnakFormatter::__construct |
( |
string |
$format, |
|
|
PropertyDataTypeLookup |
$dataTypeLookup, |
|
|
array |
$formattersBySnakType, |
|
|
array |
$formattersByDataType |
|
) |
| |
- Parameters
-
string | $format | The output format generated by this formatter. All SnakFormatters provided via $formattersBySnakType and $formattersByDataType must be safe for this output format. This is checked by comparing the $format with what each SnakFormatter returns from getFormat(). MIME parameters are ignored for this check, so FORMAT_HTML is considered compatible with FORMAT_HTML_DIFF, etc. |
PropertyDataTypeLookup | $dataTypeLookup | |
SnakFormatter[] | $formattersBySnakType | An associative array mapping snak types to SnakFormatter objects. If no formatter is defined for the a given snak type, $formattersByDataType will be checked for a SnakFormatter for the snak's data type. |
SnakFormatter[] | $formattersByDataType | An associative array mapping data types to SnakFormatter objects. If no formatter is defined for the a given data type, the "*" key in this array is checked for a default formatter. |
- Exceptions
-
InvalidArgumentException | If any of the given formatters is incompatible with $format. Formats are assumed to be represented by MIME types, MIME parameters are ignored. |
◆ assertFormatterArray()
Wikibase\Lib\Formatters\DispatchingSnakFormatter::assertFormatterArray |
( |
|
$format, |
|
|
array |
$formatters |
|
) |
| |
|
private |
◆ formatSnak()
Wikibase\Lib\Formatters\DispatchingSnakFormatter::formatSnak |
( |
Snak |
$snak | ) |
|
◆ getBaseFormat()
Wikibase\Lib\Formatters\DispatchingSnakFormatter::getBaseFormat |
( |
|
$format | ) |
|
|
private |
- Parameters
-
- Returns
- string MIME type with parameters stripped.
◆ getFormat()
Wikibase\Lib\Formatters\DispatchingSnakFormatter::getFormat |
( |
| ) |
|
◆ getSnakDataType()
Wikibase\Lib\Formatters\DispatchingSnakFormatter::getSnakDataType |
( |
Snak |
$snak | ) |
|
|
private |
- Parameters
-
- Exceptions
-
PropertyDataTypeLookupException | |
- Returns
- string The Snak's data type
◆ $dataTypeLookup
Wikibase\Lib\Formatters\DispatchingSnakFormatter::$dataTypeLookup |
|
private |
◆ $format
Wikibase\Lib\Formatters\DispatchingSnakFormatter::$format |
|
private |
◆ $formattersByDataType
Wikibase\Lib\Formatters\DispatchingSnakFormatter::$formattersByDataType |
|
private |
◆ $formattersBySnakType
Wikibase\Lib\Formatters\DispatchingSnakFormatter::$formattersBySnakType |
|
private |
The documentation for this class was generated from the following file: