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 ( $format, PropertyDataTypeLookup $dataTypeLookup, array $formattersBySnakType, array $formattersByDataType) |
|
| formatSnak (Snak $snak) |
|
| getFormat () |
|
|
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.
|
|
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 |
( |
|
$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 |
- Parameters
-
string | $format | MIME type |
SnakFormatter[] | $formatters | |
- Exceptions
-
◆ formatSnak()
Wikibase\Lib\Formatters\DispatchingSnakFormatter::formatSnak |
( |
Snak |
$snak | ) |
|
- See also
- SnakFormatter::formatSnak
Formats the given Snak by finding an appropriate formatter among the ones supplied to the constructor, and applying it.
- Parameters
-
- Exceptions
-
FormattingException | |
PropertyDataTypeLookupException | |
- Returns
- string The formatted snak value, in the format specified by getFormat().
Implements Wikibase\Lib\Formatters\SnakFormatter.
◆ 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: