Add getters to Message object.
authordaniel <daniel.kinzler@wikimedia.de>
Tue, 19 Feb 2013 19:28:57 +0000 (20:28 +0100)
committerdaniel <daniel.kinzler@wikimedia.de>
Tue, 19 Feb 2013 19:30:36 +0000 (20:30 +0100)
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
includes/Status.php

index 8d8cdee..6e533a3 100644 (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
index 4298aee..449b656 100644 (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 );