/**
* Create a new object to replace this stub object.
+ * @return object
*/
function _newObject() {
return MWFunction::newObj( $this->mClass, $this->mParams );
function _unstub( $name = '_unstub', $level = 2 ) {
static $recursionLevel = 0;
- if ( !($GLOBALS[$this->mGlobal] instanceof StubObject) )
+ if ( !($GLOBALS[$this->mGlobal] instanceof StubObject) ) {
return $GLOBALS[$this->mGlobal]; // already unstubbed.
-
+ }
+
if ( get_class( $GLOBALS[$this->mGlobal] ) != $this->mClass ) {
$fname = __METHOD__.'-'.$this->mGlobal;
wfProfileIn( $fname );
/**
* Stub object for the content language of this wiki. This object have to be in
* $wgContLang global.
+ *
+ * @deprecated since 1.18
*/
class StubContLang extends StubObject {
function __construct() {
+ wfDeprecated( __CLASS__, '1.18' );
parent::__construct( 'wgContLang' );
}
return $this->_call( $name, $args );
}
+ /**
+ * @return Language
+ */
function _newObject() {
global $wgLanguageCode;
$obj = Language::factory( $wgLanguageCode );
}
/**
- * Stub object for the $wg globals replaced by RequestContext
+ * Stub object for the user language. It depends of the user preferences and
+ * "uselang" parameter that can be passed to index.php. This object have to be
+ * in $wgLang global.
*/
-class StubRequestContext extends StubObject {
-
- private $method = null;
-
- function __construct( $global, $method ) {
- parent::__construct( $global, 'RequestContext' );
- $this->method = $method;
- }
-
- function __call( $name, $args ) {
- return $this->_call( $name, $args );
- }
-
- function __get( $name ) {
- // __get doesn't seam to play nice with _unstub
- return RequestContext::getMain()->{$this->method}()->{$name};
- }
-
- function __set( $name, $val ) {
- // __set doesn't seam to play nice with _unstub
- RequestContext::getMain()->{$this->method}()->{$name} = $val;
- }
+class StubUserLang extends StubObject {
- function __isset( $name ) {
- // __isset doesn't seam to play nice with _unstub
- return isset( RequestContext::getMain()->{$this->method}()->{$name} );
+ function __construct() {
+ parent::__construct( 'wgLang' );
}
- function __unset( $name ) {
- // __unset doesn't seam to play nice with _unstub
- unset( RequestContext::getMain()->{$this->method}()->{$name} );
+ function __call( $name, $args ) {
+ return $this->_call( $name, $args );
}
+ /**
+ * @return Language
+ */
function _newObject() {
- return RequestContext::getMain()->{$this->method}();
+ return RequestContext::getMain()->getLanguage();
}
-
}
-