MediaWiki 1.43.1
RawMessage.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Language;
22
24
39class RawMessage extends Message {
40
51 public function __construct( string $text, $params = [] ) {
52 parent::__construct( $text, $params );
53
54 // The key is the message.
55 $this->message = $text;
56 }
57
63 public function fetchMessage() {
64 // Just in case the message is unset somewhere.
65 $this->message ??= $this->key;
66
67 return $this->message;
68 }
69
70 public function getTextOfRawMessage() {
71 return $this->key;
72 }
73
74 public function getParamsOfRawMessage() {
75 return $this->parameters;
76 }
77
83 public function getKey() {
84 return 'rawmessage';
85 }
86
92 public function getParams() {
93 // If the provided text is equivalent to 'rawmessage', return the provided params.
94 if ( $this->key === '$1' ) {
95 return $this->parameters;
96 }
97 // If there are no provided params, return the provided text as the single param.
98 if ( !$this->parameters ) {
99 return [ $this->key ];
100 }
101 // As a last resort, substitute the provided params into the single param accepted by
102 // 'rawmessage'. This may access global state.
103 return [ $this->plain() ];
104 }
105
106}
107
109class_alias( RawMessage::class, 'RawMessage' );
array $params
The job parameters.
Variant of the Message class.
fetchMessage()
Fetch the message (in this case, the key).
getKey()
To conform to the MessageSpecifier interface, always return 'rawmessage', which is a real message key...
__construct(string $text, $params=[])
Call the parent constructor, then store the key as the message.
getParams()
To conform to the MessageSpecifier interface, return parameters that are valid with the 'rawmessage' ...
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:156
string $key
The message key.
Definition Message.php:204
MessageParam Message string int float[] $parameters
List of parameters which will be substituted into the message.
Definition Message.php:222
plain()
Returns the message text as-is, only parameters are substituted.
Definition Message.php:1138
string null false $message
Definition Message.php:243