*/
private $skin;
+ /**
+ * @var SiteConfiguration
+ */
+ private $config;
+
/**
* Constructor
* @param IContextSource $context Context to inherit from
$this->setContext( $context );
}
+ /**
+ * Set the SiteConfiguration object
+ *
+ * @param SiteConfiguration $c
+ */
+ public function setConfig( SiteConfiguration $s ) {
+ $this->config = $s;
+ }
+
+ /**
+ * Get the SiteConfiguration object
+ *
+ * @return SiteConfiguration
+ */
+ public function getConfig() {
+ if ( !is_null( $this->config ) ) {
+ return $this->config;
+ } else {
+ return $this->getContext()->getConfig();
+ }
+ }
+
/**
* Set the WebRequest object
*
* Set the Title object
*
* @param Title $t
+ * @throws MWException
*/
- public function setTitle( Title $t ) {
+ public function setTitle( $t ) {
+ if ( $t !== null && !$t instanceof Title ) {
+ throw new MWException( __METHOD__ . " expects an instance of Title" );
+ }
$this->title = $t;
}
return $this->getContext()->getSkin();
}
}
+
+ /**
+ * Get a message using the current context.
+ *
+ * This can't just inherit from ContextSource, since then
+ * it would set only the original context, and not take
+ * into account any changes.
+ *
+ * @param String Message name
+ * @param Variable number of message arguments
+ * @return Message
+ */
+ public function msg() {
+ $args = func_get_args();
+
+ return call_user_func_array( 'wfMessage', $args )->setContext( $this );
+ }
}