Add getters to Message object.

Being able to get the message key and parameters from a Message object
is needed to be able to report errors from the API in an abstract,
language neutral way.

Change-Id: I8ee9da4005db7cb0a487457127f1e24fb11dbd66
This commit is contained in:
daniel 2013-02-19 20:28:57 +01:00
parent cc19a196a4
commit c0f47c445a
2 changed files with 37 additions and 0 deletions

View file

@ -226,6 +226,39 @@ class Message {
$this->language = $wgLang;
}
/**
* Returns the message key
*
* @since 1.21
*
* @return string
*/
public function getKey() {
return $this->key;
}
/**
* Returns the message parameters
*
* @since 1.21
*
* @return string[]
*/
public function getParams() {
return $this->parameters;
}
/**
* Returns the message format
*
* @since 1.21
*
* @return string
*/
public function getFormat() {
return $this->format;
}
/**
* Factory function that is just wrapper for the real constructor. It is
* intented to be used instead of the real constructor, because it allows

View file

@ -231,6 +231,10 @@ class Status {
/**
* Get the error message as HTML. This is done by parsing the wikitext error
* message.
*
* @note: this does not perform a full wikitext to HTML conversion, it merely applies
* a message transformation.
* @todo: figure out whether that is actually The Right Thing.
*/
public function getHTML( $shortContext = false, $longContext = false ) {
$text = $this->getWikiText( $shortContext, $longContext );