Go to the documentation of this file.
7 '{blankVer}' => self::BLANK_VERSION
14 'msg' =>
'Empty registry',
17 mw.loader.addSource( {
18 "local": "/w/load.php"
20 mw.loader.register( [] );'
23 'msg' =>
'Basic registry',
28 mw.loader.addSource( {
29 "local": "/w/load.php"
39 'msg' =>
'Omit raw modules from registry',
45 mw.loader.addSource( {
46 "local": "/w/load.php"
56 'msg' =>
'Version falls back gracefully if getVersionHash throws',
59 ( $mock = $this->getMockBuilder(
'ResourceLoaderTestModule' )
60 ->setMethods( [
'getVersionHash' ] )->getMock() )
61 && $mock->method(
'getVersionHash' )->will(
62 $this->throwException(
new Exception )
67 mw.loader.addSource( {
68 "local": "/w/load.php"
81 'msg' =>
'Use version from getVersionHash',
84 ( $mock = $this->getMockBuilder(
'ResourceLoaderTestModule' )
85 ->setMethods( [
'getVersionHash' ] )->getMock() )
86 && $mock->method(
'getVersionHash' )->willReturn(
'1234567' )
90 mw.loader.addSource( {
91 "local": "/w/load.php"
101 'msg' =>
'Re-hash version from getVersionHash if too long',
104 ( $mock = $this->getMockBuilder(
'ResourceLoaderTestModule' )
105 ->setMethods( [
'getVersionHash' ] )->getMock() )
106 && $mock->method(
'getVersionHash' )->willReturn(
'12345678' )
110 mw.loader.addSource( {
111 "local": "/w/load.php"
113 mw.loader.register( [
121 'msg' =>
'Group signature',
128 mw.loader.addSource( {
129 "local": "/w/load.php"
131 mw.loader.register( [
151 'msg' =>
'Different target (non-test should not be registered)',
157 mw.loader.addSource( {
158 "local": "/w/load.php"
160 mw.loader.register( [
168 'msg' =>
'Foreign source',
171 'loadScript' =>
'http://example.org/w/load.php',
172 'apiScript' =>
'http://example.org/w/api.php',
179 mw.loader.addSource( {
180 "local": "/w/load.php",
181 "example": "http://example.org/w/load.php"
183 mw.loader.register( [
194 'msg' =>
'Conditional dependency function',
198 'skipFunction' =>
'return true;'
217 mw.loader.addSource( {
218 "local": "/w/load.php"
220 mw.loader.register( [
239 "return !!( window.JSON \u0026\u0026 JSON.parse \u0026\u0026 JSON.stringify);"
257 'msg' =>
'Advanced (everything combined)',
260 'loadScript' =>
'http://example.org/w/load.php',
261 'apiScript' =>
'http://example.org/w/api.php',
302 'source' =>
'example',
305 'targets' => [
'x-foo' ],
308 'source' =>
'example',
309 'targets' => [
'x-foo' ],
313 mw.loader.addSource( {
314 "local": "/w/load.php",
315 "example": "http://example.org/w/load.php"
317 mw.loader.register( [
393 if ( isset( $case[
'sources'] ) ) {
394 $this->
setMwGlobals(
'wgResourceLoaderSources', $case[
'sources'] );
398 $rl =
$context->getResourceLoader();
399 $rl->register( $case[
'modules'] );
401 $out = ltrim( $case[
'out'],
"\n" );
405 $this->
setLogger(
'exception',
new Psr\Log\NullLogger() );
408 self::expandPlaceholders(
$out ),
409 $module->getModuleRegistrations(
$context ),
440 $rl =
$context->getResourceLoader();
443 $out =
'mw.loader.addSource({"local":"/w/load.php"});' .
"\n"
444 .
'mw.loader.register(['
445 .
'["test.blank","{blankVer}"],'
446 .
'["test.min","{blankVer}",[0],null,null,'
447 .
'"return!!(window.JSON\u0026\u0026JSON.parse\u0026\u0026JSON.stringify);"'
451 self::expandPlaceholders(
$out ),
452 $module->getModuleRegistrations(
$context ),
463 $rl =
$context->getResourceLoader();
467 'mw.loader.addSource( {
468 "local": "/w/load.php"
470 mw.loader.register( [
483 "return !!( window.JSON \u0026\u0026 JSON.parse \u0026\u0026 JSON.stringify);"
488 self::expandPlaceholders(
$out ),
489 $module->getModuleRegistrations(
$context ),
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
static expandPlaceholders( $text)
testRegistrationsMinified( $modules)
ResourceLoaderStartUpModule::getModuleRegistrations provideRegistrations.
testGetModuleRegistrations( $case)
provideGetModuleRegistrations ResourceLoaderStartUpModule::getModuleRegistrations ResourceLoaderStart...
testRegistrationsUnminified( $modules)
ResourceLoaderStartUpModule::getModuleRegistrations provideRegistrations.
static provideRegistrations()
getResourceLoaderContext( $options=[], ResourceLoader $rl=null)
provideGetModuleRegistrations()
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out