*/
protected $title = null;
+ /**
+ * Content object representing the message
+ */
+ protected $content = null;
+
/**
* @var string
*/
* turned off.
* @since 1.17
* @param $lang Mixed: language code or Language object.
+ * @throws MWException
* @return Message: $this
*/
public function inLanguage( $lang ) {
return $this;
}
+ /**
+ * Returns the message as a Content object.
+ * @return Content
+ */
+ public function content() {
+ if ( !$this->content ) {
+ $this->content = new MessageContent( $this->key );
+ }
+
+ return $this->content;
+ }
+
/**
* Returns the message parsed from wikitext to HTML.
* @since 1.17
} elseif ( !is_array( $param ) ) {
return array( 'before', $param );
} else {
- throw new MWException( "Invalid message parameter" );
+ throw new MWException( "Invalid message parameter: " . serialize( $param ) );
}
}
* @return string Wikitext parsed into HTML
*/
protected function parseText( $string ) {
- return MessageCache::singleton()->parse( $string, $this->title, /*linestart*/true, $this->interface, $this->language )->getText();
+ $out = MessageCache::singleton()->parse( $string, $this->title, /*linestart*/true, $this->interface, $this->language );
+ return is_object( $out ) ? $out->getText() : $out;
}
/**
/**
* Wrapper for what ever method we use to get message contents
* @since 1.17
+ * @throws MWException
* @return string
*/
protected function fetchMessage() {