},
'ResourceLoader' => function ( MediaWikiServices $services ) : ResourceLoader {
- return new ResourceLoader(
- $services->getMainConfig(),
+ $config = $services->getMainConfig();
+
+ $rl = new ResourceLoader(
+ $config,
LoggerFactory::getInstance( 'resourceloader' )
);
+ $rl->addSource( $config->get( 'ResourceLoaderSources' ) );
+
+ return $rl;
},
'RevisionFactory' => function ( MediaWikiServices $services ) : RevisionFactory {
// Add 'local' source first
$this->addSource( 'local', $config->get( 'LoadScript' ) );
- // Add other sources
- $this->addSource( $config->get( 'ResourceLoaderSources' ) );
-
// Register core modules
$this->register( include "$IP/resources/Resources.php" );
// Register extension modules
// Avoid influence from wgInvalidateCacheOnLocalSettingsChange
'CacheEpoch' => '20140101000000',
- // For ResourceLoader::__construct()
- 'ResourceLoaderSources' => [],
-
// For wfScript()
'ScriptPath' => '/w',
'Script' => '/w/index.php',
protected static function makeContext( $extraQuery = [] ) {
$conf = new HashConfig( [
- 'ResourceLoaderSources' => [],
'ResourceModuleSkinStyles' => [],
'ResourceModules' => [],
'EnableJavaScriptTest' => false,
* @covers ResourceLoader::makeLoaderRegisterScript
*/
public function testGetModuleRegistrations( $case ) {
- if ( isset( $case['sources'] ) ) {
- $this->setMwGlobals( 'wgResourceLoaderSources', $case['sources'] );
- }
-
$extraQuery = $case['extraQuery'] ?? [];
$context = $this->getResourceLoaderContext( $extraQuery );
$rl = $context->getResourceLoader();
+ if ( isset( $case['sources'] ) ) {
+ $rl->addSource( $case['sources'] );
+ }
$rl->register( $case['modules'] );
$module = new ResourceLoaderStartUpModule();
$out = ltrim( $case['out'], "\n" );
* @covers ResourceLoader::getLoadScript
*/
public function testGetLoadScript() {
- $this->setMwGlobals( 'wgResourceLoaderSources', [] );
$rl = new ResourceLoader();
$sources = self::fakeSources();
$rl->addSource( $sources );