X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fcontext%2FDerivativeContext.php;h=f7a1815d023e2f8c9c14ee32eccb3c02582d41cf;hb=21551d2d15f2262695ad9d56d38ae0af7d942ad9;hp=aaa1fa7d3dc3f0a435ea1a3a3eea6503f5c2b000;hpb=1224a70009542dc72d371978fd7ba7195206a852;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/context/DerivativeContext.php b/includes/context/DerivativeContext.php index aaa1fa7d3d..f7a1815d02 100644 --- a/includes/context/DerivativeContext.php +++ b/includes/context/DerivativeContext.php @@ -18,6 +18,7 @@ * @author Daniel Friesen * @file */ +use MediaWiki\MediaWikiServices; /** * An IContextSource implementation which will inherit context from another source @@ -26,7 +27,7 @@ * a different Title instance set on it. * @since 1.19 */ -class DerivativeContext extends ContextSource { +class DerivativeContext extends ContextSource implements MutableContext { /** * @var WebRequest */ @@ -68,12 +69,11 @@ class DerivativeContext extends ContextSource { private $config; /** - * @var Stats + * @var Timing */ - private $stats; + private $timing; /** - * Constructor * @param IContextSource $context Context to inherit from */ public function __construct( IContextSource $context ) { @@ -81,17 +81,13 @@ class DerivativeContext extends ContextSource { } /** - * Set the SiteConfiguration object - * - * @param Config $s + * @param Config $config */ - public function setConfig( Config $s ) { - $this->config = $s; + public function setConfig( Config $config ) { + $this->config = $config; } /** - * Get the Config object - * * @return Config */ public function getConfig() { @@ -103,30 +99,33 @@ class DerivativeContext extends ContextSource { } /** - * Get the stats object + * @deprecated since 1.27 use a StatsdDataFactory from MediaWikiServices (preferably injected) * - * @return BufferingStatsdDataFactory + * @return IBufferingStatsdDataFactory */ public function getStats() { - if ( !is_null( $this->stats ) ) { - return $this->stats; + return MediaWikiServices::getInstance()->getStatsdDataFactory(); + } + + /** + * @return Timing + */ + public function getTiming() { + if ( !is_null( $this->timing ) ) { + return $this->timing; } else { - return $this->getContext()->getStats(); + return $this->getContext()->getTiming(); } } /** - * Set the WebRequest object - * - * @param WebRequest $r + * @param WebRequest $request */ - public function setRequest( WebRequest $r ) { - $this->request = $r; + public function setRequest( WebRequest $request ) { + $this->request = $request; } /** - * Get the WebRequest object - * * @return WebRequest */ public function getRequest() { @@ -138,17 +137,13 @@ class DerivativeContext extends ContextSource { } /** - * Set the Title object - * - * @param Title $t + * @param Title $title */ - public function setTitle( Title $t ) { - $this->title = $t; + public function setTitle( Title $title ) { + $this->title = $title; } /** - * Get the Title object - * * @return Title|null */ public function getTitle() { @@ -178,13 +173,11 @@ class DerivativeContext extends ContextSource { } /** - * Set the WikiPage object - * * @since 1.19 - * @param WikiPage $p + * @param WikiPage $wikiPage */ - public function setWikiPage( WikiPage $p ) { - $this->wikipage = $p; + public function setWikiPage( WikiPage $wikiPage ) { + $this->wikipage = $wikiPage; } /** @@ -205,17 +198,13 @@ class DerivativeContext extends ContextSource { } /** - * Set the OutputPage object - * - * @param OutputPage $o + * @param OutputPage $output */ - public function setOutput( OutputPage $o ) { - $this->output = $o; + public function setOutput( OutputPage $output ) { + $this->output = $output; } /** - * Get the OutputPage object - * * @return OutputPage */ public function getOutput() { @@ -227,17 +216,13 @@ class DerivativeContext extends ContextSource { } /** - * Set the User object - * - * @param User $u + * @param User $user */ - public function setUser( User $u ) { - $this->user = $u; + public function setUser( User $user ) { + $this->user = $user; } /** - * Get the User object - * * @return User */ public function getUser() { @@ -249,18 +234,16 @@ class DerivativeContext extends ContextSource { } /** - * Set the Language object - * - * @param Language|string $l Language instance or language code + * @param Language|string $language Language instance or language code * @throws MWException * @since 1.19 */ - public function setLanguage( $l ) { - if ( $l instanceof Language ) { - $this->lang = $l; - } elseif ( is_string( $l ) ) { - $l = RequestContext::sanitizeLangCode( $l ); - $obj = Language::factory( $l ); + public function setLanguage( $language ) { + if ( $language instanceof Language ) { + $this->lang = $language; + } elseif ( is_string( $language ) ) { + $language = RequestContext::sanitizeLangCode( $language ); + $obj = Language::factory( $language ); $this->lang = $obj; } else { throw new MWException( __METHOD__ . " was passed an invalid type of data." ); @@ -268,8 +251,6 @@ class DerivativeContext extends ContextSource { } /** - * Get the Language object - * * @return Language * @since 1.19 */ @@ -282,18 +263,14 @@ class DerivativeContext extends ContextSource { } /** - * Set the Skin object - * - * @param Skin $s + * @param Skin $skin */ - public function setSkin( Skin $s ) { - $this->skin = clone $s; + public function setSkin( Skin $skin ) { + $this->skin = clone $skin; $this->skin->setContext( $this ); } /** - * Get the Skin object - * * @return Skin */ public function getSkin() { @@ -311,10 +288,12 @@ class DerivativeContext extends ContextSource { * it would set only the original context, and not take * into account any changes. * + * @param string|string[]|MessageSpecifier $key Message key, or array of keys, + * or a MessageSpecifier. * @param mixed $args,... Arguments to wfMessage * @return Message */ - public function msg() { + public function msg( $key ) { $args = func_get_args(); return call_user_func_array( 'wfMessage', $args )->setContext( $this );