MediaWiki  master
ResourceLoader\HookRunner Class Reference
Inheritance diagram for ResourceLoader\HookRunner:
Collaboration diagram for ResourceLoader\HookRunner:

Public Member Functions

 __construct (HookContainer $container)
 
 onResourceLoaderExcludeUserOptions (array &$keysToExclude, ResourceLoaderContext $context)
 Exclude a user option from the preloaded data for client-side mw.user.options. More...
 
 onResourceLoaderForeignApiModules (&$dependencies, $context)
 Add dependencies to the mediawiki.ForeignApi module when you wish to override its behavior. More...
 
 onResourceLoaderRegisterModules (ResourceLoader $rl)
 This hook is called right before modules information is required, such as when responding to a resource loader request or generating HTML output. More...
 
 onResourceLoaderSiteModulePages ( $skin, array &$pages)
 Change which wiki pages comprise the site module in given skin. More...
 
 onResourceLoaderSiteStylesModulePages ( $skin, array &$pages)
 Change which wiki pages comprise the site.styles module in given skin. More...
 
 onResourceLoaderTestModules (array &$testModules, ResourceLoader $rl)
 Use this hook to register ResourceLoader modules that are only available when $wgEnableJavaScriptTest is true. More...
 

Private Attributes

HookContainer $container
 

Detailed Description

Access: internal

Definition at line 14 of file HookRunner.php.

Constructor & Destructor Documentation

◆ __construct()

ResourceLoader\HookRunner::__construct ( HookContainer  $container)

Definition at line 25 of file HookRunner.php.

References ResourceLoader\HookRunner\$container.

Member Function Documentation

◆ onResourceLoaderExcludeUserOptions()

ResourceLoader\HookRunner::onResourceLoaderExcludeUserOptions ( array &  $keysToExclude,
ResourceLoaderContext  $context 
)

Exclude a user option from the preloaded data for client-side mw.user.options.

This hook is called on every index.php pageview (via ResourceLoaderUserOptionsModule), and when building responses for the "mediawiki.base" module. Avoid database queries or other expensive operations as that would increase page load time.

Use this hook to optimize pageview HTML size by omitting user preference values from the export JavaScript data for mw.user.options. For example, when an extension stores large values in a user preference, and rarely or never needs these client-side, you can exclude it via this hook. (T251994)

This will exclude both the default value (via mediawiki.base module) and the current user's value (via pageview HTML).

Since
1.38
Parameters
array&$keysToExclude
ResourceLoaderContext$context
Returns
void

Implements ResourceLoader\Hook\ResourceLoaderExcludeUserOptionsHook.

Definition at line 29 of file HookRunner.php.

◆ onResourceLoaderForeignApiModules()

ResourceLoader\HookRunner::onResourceLoaderForeignApiModules ( $dependencies,
  $context 
)

Add dependencies to the mediawiki.ForeignApi module when you wish to override its behavior.

See the JS docs for more information.

This hook is called from ResourceLoaderForeignApiModule.

Since
1.35
Parameters
string[]&$dependenciesList of modules that mediawiki.ForeignApi should depend on
ResourceLoaderContext | null$context
Returns
void This hook must not abort, it must return no value

Implements ResourceLoader\Hook\ResourceLoaderForeignApiModulesHook.

Definition at line 37 of file HookRunner.php.

◆ onResourceLoaderRegisterModules()

ResourceLoader\HookRunner::onResourceLoaderRegisterModules ( ResourceLoader  $rl)

This hook is called right before modules information is required, such as when responding to a resource loader request or generating HTML output.

Since
1.35
Parameters
ResourceLoader$rl
Returns
void This hook must not abort, it must return no value

Implements ResourceLoader\Hook\ResourceLoaderRegisterModulesHook.

Definition at line 45 of file HookRunner.php.

◆ onResourceLoaderSiteModulePages()

ResourceLoader\HookRunner::onResourceLoaderSiteModulePages (   $skin,
array &  $pages 
)

Change which wiki pages comprise the site module in given skin.

This hook is called from ResourceLoaderSiteModule.

Since
1.35
Parameters
string$skinCurrent skin key
array&$pagesArray of pages and their types
Returns
void This hook must not abort, it must return no value

Implements ResourceLoader\Hook\ResourceLoaderSiteModulePagesHook.

Definition at line 53 of file HookRunner.php.

◆ onResourceLoaderSiteStylesModulePages()

ResourceLoader\HookRunner::onResourceLoaderSiteStylesModulePages (   $skin,
array &  $pages 
)

Change which wiki pages comprise the site.styles module in given skin.

This hook is called from ResourceLoaderSiteStylesModule.

Since
1.35
Parameters
string$skinCurrent skin key
array&$pagesArray of pages and their types
Returns
void This hook must not abort, it must return no value

Implements ResourceLoader\Hook\ResourceLoaderSiteStylesModulePagesHook.

Definition at line 61 of file HookRunner.php.

◆ onResourceLoaderTestModules()

ResourceLoader\HookRunner::onResourceLoaderTestModules ( array &  $testModules,
ResourceLoader  $rl 
)

Use this hook to register ResourceLoader modules that are only available when $wgEnableJavaScriptTest is true.

Use this for test suites and other test-only resources.

Since
1.35
Parameters
array&$testModulesOne array of modules per test framework. The modules array follows the same format as $wgResourceModules. For example: $testModules['qunit']['ext.Example.test'] = [ 'localBasePath' => DIR . '/tests/qunit', 'remoteExtPath' => 'Example/tests/qunit', 'script' => [ 'tests/qunit/foo.js' ], 'dependencies' => [ 'ext.Example.foo' ] ];
ResourceLoader$rl
Returns
void This hook must not abort, it must return no value

Implements ResourceLoader\Hook\ResourceLoaderTestModulesHook.

Definition at line 69 of file HookRunner.php.

Member Data Documentation

◆ $container

HookContainer ResourceLoader\HookRunner::$container
private

Definition at line 23 of file HookRunner.php.

Referenced by ResourceLoader\HookRunner\__construct().


The documentation for this class was generated from the following file: