DispatchingValueFormatter is a formatter for DataValues.
More...
DispatchingValueFormatter is a formatter for DataValues.
In addition to dispatching based on the DataValue type, it also supports dispatching based on a DataType.
- Todo
- Plain format() shouldn't be supported, formatValue() should require the dataType ID.
- Copyright
- GPL-2.0-or-later
- Author
- Daniel Kinzler
◆ __construct()
Wikibase\Lib\Formatters\DispatchingValueFormatter::__construct |
( |
array | $formatters | ) |
|
- Parameters
-
ValueFormatter[] | $formatters | Maps prefixed type ids to ValueFormatter instances. Each type ID must be prefixed with either "PT:" for property data types or "VT:" for data value types. |
- Exceptions
-
◆ format()
Wikibase\Lib\Formatters\DispatchingValueFormatter::format |
( |
| $value | ) |
|
- See also
- ValueFormatter::format
- Deprecated
- Use formatValue() instead
- Parameters
-
DataValue | $value | The value to format |
- Exceptions
-
- Returns
- string
◆ formatValue()
Wikibase\Lib\Formatters\DispatchingValueFormatter::formatValue |
( |
DataValue | $value, |
|
|
| $dataTypeId = null ) |
- See also
- ValueFormatter::format
Formats the given value by finding an appropriate formatter among the ones supplied to the constructor, and applying it.
If $dataTypeId is given, this will first try to find an appropriate formatter based on the data type. If none is found, this falls back to finding a formatter based on the value's type.
- See also
- TypedValueFormatter::formatValue
- Parameters
-
DataValue | $value | |
string | null | $dataTypeId | |
- Exceptions
-
- Returns
- string
Implements Wikibase\Lib\Formatters\TypedValueFormatter.
◆ $formatters
Wikibase\Lib\Formatters\DispatchingValueFormatter::$formatters |
|
private |
The documentation for this class was generated from the following file: