From c0f47c445a075db4f5d19baccef493fdab022579 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 19 Feb 2013 20:28:57 +0100 Subject: [PATCH] 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 --- includes/Message.php | 33 +++++++++++++++++++++++++++++++++ includes/Status.php | 4 ++++ 2 files changed, 37 insertions(+) diff --git a/includes/Message.php b/includes/Message.php index 8d8cdeeb70..6e533a317e 100644 --- a/includes/Message.php +++ b/includes/Message.php @@ -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 diff --git a/includes/Status.php b/includes/Status.php index 4298aee984..449b656b2e 100644 --- a/includes/Status.php +++ b/includes/Status.php @@ -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 ); -- 2.20.1