|
MediaWiki master
|
Value object representing a message for i18n with alternative machine-readable data. More...
Inherits Wikimedia\Message\MessageValue.

Public Member Functions | |
| __construct (string $key, array $params=[], ?string $code=null, ?array $data=null) | |
| dump () | |
| Dump the object for testing/debugging. | |
| getCode () | |
| Get the message code. | |
| getData () | |
| Get the message's structured data. | |
| isSameAs (MessageValue $mv) | |
| toJsonArray () | |
Public Member Functions inherited from Wikimedia\Message\MessageValue | |
| __construct (string $key, array $params=[]) | |
| bitrateParams (... $values) | |
| Chainable mutator which adds parameters which are a number of bits per second (ParamType::BITRATE). | |
| commaListParams (... $values) | |
| Chainable mutator which adds comma lists (ListType::COMMA). | |
| dateParams (... $values) | |
| Chainable mutator which adds parameters which are a date timestamp (ParamType::DATE). | |
| dateTimeParams (... $values) | |
| Chainable mutator which adds parameters which are a date-time timestamp (ParamType::DATETIME). | |
| expiryParams (... $values) | |
| Chainable mutator which adds parameters which are an expiry timestamp (ParamType::EXPIRY). | |
| getKey () | |
| Get the message key. | |
| getParams () | |
| Get the parameter array. | |
| listParamsOfType (string|ListType $listType,... $values) | |
| Chainable mutator which adds list parameters with a common type. | |
| longDurationParams (... $values) | |
| Chainable mutator which adds parameters which are a duration specified in seconds (ParamType::DURATION_LONG). | |
| numParams (... $values) | |
| Chainable mutator which adds numeric parameters (ParamType::NUM). | |
| params (... $values) | |
| Chainable mutator which adds text parameters and MessageParam parameters. | |
| pipeListParams (... $values) | |
| Chainable mutator which adds pipe lists (ListType::PIPE). | |
| plaintextParams (... $values) | |
| Chainable mutator which adds plaintext parameters (ParamType::PLAINTEXT). | |
| rawParams (... $values) | |
| Chainable mutator which adds "raw" parameters (ParamType::RAW). | |
| semicolonListParams (... $values) | |
| Chainable mutator which adds semicolon lists (ListType::SEMICOLON). | |
| shortDurationParams (... $values) | |
| Chainable mutator which adds parameters which are a duration specified in seconds (ParamType::DURATION_SHORT). | |
| sizeParams (... $values) | |
| Chainable mutator which adds parameters which are a number of bytes (ParamType::SIZE). | |
| textListParams (... $values) | |
| Chainable mutator which adds natural-language lists (ListType::AND). | |
| textParams (... $values) | |
| Chainable mutator which adds parameters of type text (ParamType::TEXT). | |
| textParamsOfType (string|ParamType $type,... $values) | |
| Chainable mutator which adds text parameters with a common type. | |
| timeParams (... $values) | |
| Chainable mutator which adds parameters which are a time timestamp (ParamType::TIME). | |
| userGroupParams (... $values) | |
| Chainable mutator which adds parameters which are a user group (ParamType::GROUP). | |
Static Public Member Functions | |
| static | jsonClassHintFor (string $keyName) |
| static | new (string $key, array $params=[], ?string $code=null, ?array $data=null) |
Static constructor for easier chaining of ->params() methods. | |
| static | newFromJsonArray (array $json) |
Static Public Member Functions inherited from Wikimedia\Message\MessageValue | |
| static | hint () |
| If you are serializing a MessageValue (or a DataMessageValue), use this JsonCodec hint to suppress unnecessary type information. | |
| static | new (string $key, array $params=[]) |
Static constructor for easier chaining of ->params() methods. | |
| static | newFromSpecifier (MessageSpecifier $spec) |
| Convert from any MessageSpecifier to a MessageValue. | |
Value object representing a message for i18n with alternative machine-readable data.
This augments a MessageValue with an additional machine-readable code and structured data. The intended use is to facilitate error reporting in APIs.
For example, a MessageValue reporting an "integer out of range" error might use one of three message keys, depending on whether there is a minimum, a maximum, or both. But an API would likely want to use one code for all three cases, and would likely want the endpoints represented along the lines of ‘[ 'min’ => 1, 'max' => 10 ]rather than [ 0 => new ScalarParam( ParamType::TEXT, 1 ), 1 => new ScalarParam( ParamType::TEXT, 10 ) ]`.
DataMessageValues are pure value objects and are newable and (de)serializable.
Definition at line 25 of file DataMessageValue.php.
| Wikimedia\Message\DataMessageValue::__construct | ( | string | $key, |
| array | $params = [], | ||
| ?string | $code = null, | ||
| ?array | $data = null ) |
| string | $key | |
| (MessageParam|MessageValue|string|int|float)[] | $params | |
| string | null | $code | String representing the concept behind this message. |
| array | null | $data | Structured data representing the concept behind this message. |
Definition at line 41 of file DataMessageValue.php.
| Wikimedia\Message\DataMessageValue::dump | ( | ) |
Dump the object for testing/debugging.
Reimplemented from Wikimedia\Message\MessageValue.
Definition at line 82 of file DataMessageValue.php.
| Wikimedia\Message\DataMessageValue::getCode | ( | ) |
Get the message code.
Definition at line 70 of file DataMessageValue.php.
Referenced by Wikimedia\ParamValidator\ValidationException\__construct(), and MediaWiki\Api\Validator\ApiParamValidatorCallbacks\recordCondition().
| Wikimedia\Message\DataMessageValue::getData | ( | ) |
Get the message's structured data.
Definition at line 78 of file DataMessageValue.php.
Referenced by Wikimedia\ParamValidator\ValidationException\__construct(), MediaWiki\Api\Validator\ApiParamValidatorCallbacks\recordCondition(), and Wikimedia\ParamValidator\TypeDef\EnumDef\validate().
| Wikimedia\Message\DataMessageValue::isSameAs | ( | MessageValue | $mv | ) |
Reimplemented from Wikimedia\Message\MessageValue.
Definition at line 102 of file DataMessageValue.php.
|
static |
Reimplemented from Wikimedia\Message\MessageValue.
Definition at line 119 of file DataMessageValue.php.
|
static |
Static constructor for easier chaining of ->params() methods.
| string | $key | |
| (MessageParam|MessageValue|string|int|float)[] | $params | |
| string | null | $code | |
| array | null | $data |
Definition at line 58 of file DataMessageValue.php.
|
static |
Reimplemented from Wikimedia\Message\MessageValue.
Definition at line 126 of file DataMessageValue.php.
| Wikimedia\Message\DataMessageValue::toJsonArray | ( | ) |
Reimplemented from Wikimedia\Message\MessageValue.
Definition at line 109 of file DataMessageValue.php.