MediaWiki  master
ApiRawMessage.php
Go to the documentation of this file.
1 <?php
22 
29 class ApiRawMessage extends RawMessage implements IApiMessage {
30  use ApiMessageTrait;
31 
41  public function __construct( $msg, $code = null, array $data = null ) {
42  if ( $msg instanceof RawMessage ) {
43  foreach ( get_class_vars( get_class( $this ) ) as $key => $value ) {
44  if ( isset( $msg->$key ) ) {
45  $this->$key = $msg->$key;
46  }
47  }
48  } elseif ( is_array( $msg ) ) {
49  $key = array_shift( $msg );
50  parent::__construct( $key, $msg );
51  } else {
52  parent::__construct( $msg );
53  }
54  $this->setApiCode( $code, $data );
55  }
56 }
Extension of RawMessage implementing IApiMessage.
__construct( $msg, $code=null, array $data=null)
Variant of the Message class.
Definition: RawMessage.php:40
string $key
The message key.
Definition: Message.php:186
trait ApiMessageTrait
Trait to implement the IApiMessage interface for Message subclasses.
Interface for messages with machine-readable data for use by the API.
Definition: IApiMessage.php:39
setApiCode( $code, array $data=null)
Sets the machine-readable code for use by the API.