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