// Various parameters
$this->user = $request->getRawVal( 'user' );
- $this->debug = $request->getFuzzyBool(
- 'debug',
- $resourceLoader->getConfig()->get( 'ResourceLoaderDebug' )
- );
+ $this->debug = $request->getRawVal( 'debug' ) === 'true';
$this->only = $request->getRawVal( 'only', null );
$this->version = $request->getRawVal( 'version', null );
$this->raw = $request->getFuzzyBool( 'raw' );
$skinnames = Skin::getSkinNames();
// If no skin is specified, or we don't recognize the skin, use the default skin
if ( !$this->skin || !isset( $skinnames[$this->skin] ) ) {
- $this->skin = $resourceLoader->getConfig()->get( 'DefaultSkin' );
+ $this->skin = $this->getConfig()->get( 'DefaultSkin' );
}
}
/**
* Return a dummy ResourceLoaderContext object suitable for passing into
* things that don't "really" need a context.
+ *
+ * Use cases:
+ * - Creating html5shiv script tag in OutputPage.
+ * - Unit tests (deprecated, create empty instance directly or use RLTestCase).
+ *
* @return ResourceLoaderContext
*/
public static function newDummyContext() {
+ // This currently creates a non-empty instance of ResourceLoader (all modules registered),
+ // but that's probably not needed. So once that moves into ServiceWiring, this'll
+ // become more like the EmptyResourceLoader class we have in PHPUnit tests, which
+ // is what this should've had originally. If this turns out to be untrue, change to:
+ // `MediaWikiServices::getInstance()->getResourceLoader()` instead.
return new self( new ResourceLoader(
MediaWikiServices::getInstance()->getMainConfig(),
LoggerFactory::getInstance( 'resourceloader' )
return $this->resourceLoader;
}
+ /**
+ * @return Config
+ */
+ public function getConfig() {
+ return $this->getResourceLoader()->getConfig();
+ }
+
/**
* @return WebRequest
*/
$lang = $this->getRequest()->getRawVal( 'lang', '' );
// Stricter version of RequestContext::sanitizeLangCode()
if ( !Language::isValidBuiltInCode( $lang ) ) {
- $lang = $this->getResourceLoader()->getConfig()->get( 'LanguageCode' );
+ $lang = $this->getConfig()->get( 'LanguageCode' );
}
$this->language = $lang;
}