MediaWiki master
|
Value object representing a message for i18n. More...
Inherits Wikimedia\Message\MessageSpecifier, and JsonCodecable.
Inherited by Wikimedia\Message\DataMessageValue.
Public Member Functions | |
__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). | |
dump () | |
Dump the object for testing/debugging. | |
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,... $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 $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). | |
toJsonArray () | |
userGroupParams (... $values) | |
Chainable mutator which adds parameters which are a user group (ParamType::GROUP). | |
Static Public Member Functions | |
static | new (string $key, array $params=[]) |
Static constructor for easier chaining of ->params() methods. | |
static | newFromJsonArray (array $json) |
static | newFromSpecifier (MessageSpecifier $spec) |
Convert from any MessageSpecifier to a MessageValue. | |
Value object representing a message for i18n.
A MessageValue holds a key and an array of parameters. It can be converted to a string in a particular language using formatters obtained from an IMessageFormatterFactory.
MessageValues are pure value objects and are newable and (de)serializable.
Definition at line 19 of file MessageValue.php.
Wikimedia\Message\MessageValue::__construct | ( | string | $key, |
array | $params = [] ) |
string | $key | |
(MessageParam|MessageSpecifier|string|int|float)[] | $params Values that are not instances of MessageParam are wrapped using ParamType::TEXT. |
Definition at line 34 of file MessageValue.php.
References Wikimedia\Message\MessageValue\params().
Wikimedia\Message\MessageValue::bitrateParams | ( | $values | ) |
Chainable mutator which adds parameters which are a number of bits per second (ParamType::BITRATE).
int|float | ...$values |
Definition at line 248 of file MessageValue.php.
Wikimedia\Message\MessageValue::commaListParams | ( | $values | ) |
Chainable mutator which adds comma lists (ListType::COMMA).
The list parameters thus created are formatted as a comma-separated list, or some local equivalent.
(MessageParam|MessageSpecifier|string|int|float)[] | ...$values Each value is an array of items suitable to pass as $params to ListParam::__construct() |
Definition at line 290 of file MessageValue.php.
Wikimedia\Message\MessageValue::dateParams | ( | $values | ) |
Chainable mutator which adds parameters which are a date timestamp (ParamType::DATE).
string | ...$values Timestamp as accepted by the Wikimedia\Timestamp library. |
Definition at line 205 of file MessageValue.php.
Wikimedia\Message\MessageValue::dateTimeParams | ( | $values | ) |
Chainable mutator which adds parameters which are a date-time timestamp (ParamType::DATETIME).
string | ...$values Timestamp as accepted by the Wikimedia\Timestamp library. |
Definition at line 194 of file MessageValue.php.
Wikimedia\Message\MessageValue::dump | ( | ) |
Dump the object for testing/debugging.
Reimplemented in Wikimedia\Message\DataMessageValue.
Definition at line 341 of file MessageValue.php.
Wikimedia\Message\MessageValue::expiryParams | ( | $values | ) |
Chainable mutator which adds parameters which are an expiry timestamp (ParamType::EXPIRY).
string | ...$values Timestamp as accepted by the Wikimedia\Timestamp library, or "infinity" |
Definition at line 183 of file MessageValue.php.
Wikimedia\Message\MessageValue::getKey | ( | ) |
Get the message key.
Implements Wikimedia\Message\MessageSpecifier.
Definition at line 69 of file MessageValue.php.
Referenced by MediaWiki\Rest\LocalizedHttpException\__construct(), MediaWiki\Parser\ParserOutput\addWarningMsgVal(), MediaWiki\Rest\ResponseFactory\getFormattedMessage(), and MediaWiki\Api\Validator\ApiParamValidatorCallbacks\recordCondition().
Wikimedia\Message\MessageValue::getParams | ( | ) |
Get the parameter array.
Implements Wikimedia\Message\MessageSpecifier.
Definition at line 78 of file MessageValue.php.
Referenced by MediaWiki\Api\Validator\ApiParamValidatorCallbacks\recordCondition().
Wikimedia\Message\MessageValue::listParamsOfType | ( | string | $listType, |
$values ) |
Chainable mutator which adds list parameters with a common type.
string | $listType | One of the ListType constants |
(MessageParam|MessageSpecifier|string|int|float)[] | ...$values Each value is an array of items suitable to pass as $params to ListParam::__construct() |
Definition at line 121 of file MessageValue.php.
Wikimedia\Message\MessageValue::longDurationParams | ( | $values | ) |
Chainable mutator which adds parameters which are a duration specified in seconds (ParamType::DURATION_LONG).
This is similar to shorDurationParams() except that the result will be more verbose.
int|float | ...$values |
Definition at line 158 of file MessageValue.php.
|
static |
Static constructor for easier chaining of ->params()
methods.
string | $key | |
(MessageParam|MessageSpecifier|string|int|float)[] | $params |
Definition at line 46 of file MessageValue.php.
References $params.
|
static |
Reimplemented in Wikimedia\Message\DataMessageValue.
Definition at line 359 of file MessageValue.php.
|
static |
Convert from any MessageSpecifier to a MessageValue.
When the given object is an instance of MessageValue, the same object is returned.
MessageSpecifier | $spec |
Definition at line 59 of file MessageValue.php.
Referenced by Wikimedia\Message\ScalarParam\__construct().
Wikimedia\Message\MessageValue::numParams | ( | $values | ) |
Chainable mutator which adds numeric parameters (ParamType::NUM).
int|float | ...$values |
Definition at line 144 of file MessageValue.php.
Wikimedia\Message\MessageValue::params | ( | $values | ) |
Chainable mutator which adds text parameters and MessageParam parameters.
MessageParam|MessageSpecifier|string|int|float | ...$values |
Definition at line 88 of file MessageValue.php.
Referenced by Wikimedia\Message\MessageValue\__construct().
Wikimedia\Message\MessageValue::pipeListParams | ( | $values | ) |
Chainable mutator which adds pipe lists (ListType::PIPE).
The list parameters thus created are formatted as a pipe ("|") -separated list, or some local equivalent.
(MessageParam|MessageSpecifier|string|int|float)[] | ...$values Each value is an array of items suitable to pass as $params to ListParam::__construct() |
Definition at line 318 of file MessageValue.php.
Wikimedia\Message\MessageValue::plaintextParams | ( | $values | ) |
Chainable mutator which adds plaintext parameters (ParamType::PLAINTEXT).
Plaintext parameters are substituted after formatter processing. The value will be escaped by the formatter as appropriate for the target output format so as to be represented as plain text rather than as any sort of markup.
string | ...$values |
Definition at line 276 of file MessageValue.php.
Wikimedia\Message\MessageValue::rawParams | ( | $values | ) |
Chainable mutator which adds "raw" parameters (ParamType::RAW).
Raw parameters are substituted after formatter processing. The caller is responsible for ensuring that the value will be safe for the intended output format, and documenting what that intended output format is.
string | ...$values |
Definition at line 262 of file MessageValue.php.
Wikimedia\Message\MessageValue::semicolonListParams | ( | $values | ) |
Chainable mutator which adds semicolon lists (ListType::SEMICOLON).
The list parameters thus created are formatted as a semicolon-separated list, or some local equivalent.
(MessageParam|MessageSpecifier|string|int|float)[] | ...$values Each value is an array of items suitable to pass as $params to ListParam::__construct() |
Definition at line 304 of file MessageValue.php.
Wikimedia\Message\MessageValue::shortDurationParams | ( | $values | ) |
Chainable mutator which adds parameters which are a duration specified in seconds (ParamType::DURATION_SHORT).
This is similar to longDurationParams() except that the result will be more compact.
int|float | ...$values |
Definition at line 172 of file MessageValue.php.
Wikimedia\Message\MessageValue::sizeParams | ( | $values | ) |
Chainable mutator which adds parameters which are a number of bytes (ParamType::SIZE).
int | ...$values |
Definition at line 237 of file MessageValue.php.
Wikimedia\Message\MessageValue::textListParams | ( | $values | ) |
Chainable mutator which adds natural-language lists (ListType::AND).
The list parameters thus created, when formatted, are joined as in natural language. In English, this means a comma-separated list, with the last two elements joined with "and".
(MessageParam|string)[] | ...$values |
Definition at line 332 of file MessageValue.php.
Wikimedia\Message\MessageValue::textParams | ( | $values | ) |
Chainable mutator which adds parameters of type text (ParamType::TEXT).
MessageSpecifier|string|int|float | ...$values |
Definition at line 134 of file MessageValue.php.
Wikimedia\Message\MessageValue::textParamsOfType | ( | string | $type, |
$values ) |
Chainable mutator which adds text parameters with a common type.
string | $type | One of the ParamType constants |
MessageSpecifier|string|int|float | ...$values Scalar values |
Definition at line 106 of file MessageValue.php.
Wikimedia\Message\MessageValue::timeParams | ( | $values | ) |
Chainable mutator which adds parameters which are a time timestamp (ParamType::TIME).
string | ...$values Timestamp as accepted by the Wikimedia\Timestamp library. |
Definition at line 216 of file MessageValue.php.
Wikimedia\Message\MessageValue::toJsonArray | ( | ) |
Reimplemented in Wikimedia\Message\DataMessageValue.
Definition at line 350 of file MessageValue.php.
Wikimedia\Message\MessageValue::userGroupParams | ( | $values | ) |
Chainable mutator which adds parameters which are a user group (ParamType::GROUP).
string | ...$values User Groups |
Definition at line 227 of file MessageValue.php.