43 public static function create( $msg, $code =
null, array $data =
null ) {
44 if ( is_array( $msg ) ) {
46 if ( isset( $msg[
'message'] ) ) {
47 if ( isset( $msg[
'params'] ) ) {
48 $msg = array_merge( [ $msg[
'message'] ], $msg[
'params'] );
50 $msg = [ $msg[
'message'] ];
77 public function __construct( $msg, $code =
null, array $data =
null ) {
78 if ( $msg instanceof
Message ) {
79 foreach ( get_class_vars( get_class( $this ) ) as
$key => $value ) {
80 if ( isset( $msg->$key ) ) {
81 $this->
$key = $msg->$key;
84 } elseif ( is_array( $msg ) ) {
85 $key = array_shift( $msg );
86 parent::__construct(
$key, $msg );
88 parent::__construct( $msg );
setApiCode( $code, array $data=null)
Extension of Message implementing IApiMessage @newable.
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
__construct( $msg, $code=null, array $data=null)
Extension of RawMessage implementing IApiMessage @newable.
The Message class deals with fetching and processing of interface message into a variety of formats.
string $key
The message key.
Variant of the Message class.
trait ApiMessageTrait
Trait to implement the IApiMessage interface for Message subclasses.
Interface for messages with machine-readable data for use by the API.