X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fcontext%2FDerivativeContext.php;h=fd9bf96338c682e8b4c057afb171682f78bcde71;hb=fe05f85a62275e84d61edf3576cf3f03e262d56a;hp=eda56a7d55d67b72fa0412f442ae81eb6c581133;hpb=7636bea2bf3ccc33389a97d968bdda64036f59c0;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/context/DerivativeContext.php b/includes/context/DerivativeContext.php index eda56a7d55..fd9bf96338 100644 --- a/includes/context/DerivativeContext.php +++ b/includes/context/DerivativeContext.php @@ -100,7 +100,10 @@ class DerivativeContext extends ContextSource { * * @param Title $t */ - 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; } @@ -281,4 +284,20 @@ class DerivativeContext extends ContextSource { 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 ); + } }