MediaWiki master
MediaWiki\ResourceLoader\HookRunner Class Reference

Inherits MediaWiki\ResourceLoader\Hook\ResourceLoaderBeforeResponseHook, MediaWiki\ResourceLoader\Hook\ResourceLoaderExcludeUserOptionsHook, MediaWiki\ResourceLoader\Hook\ResourceLoaderForeignApiModulesHook, MediaWiki\ResourceLoader\Hook\ResourceLoaderModifyEmbeddedSourceUrlsHook, MediaWiki\ResourceLoader\Hook\ResourceLoaderRegisterModulesHook, MediaWiki\ResourceLoader\Hook\ResourceLoaderSiteModulePagesHook, MediaWiki\ResourceLoader\Hook\ResourceLoaderSiteStylesModulePagesHook, MediaWiki\ResourceLoader\Hook\ResourceLoaderGetConfigVarsHook, and MediaWiki\ResourceLoader\Hook\ResourceLoaderJqueryMsgModuleMagicWordsHook.

Collaboration diagram for MediaWiki\ResourceLoader\HookRunner:

Public Member Functions

 __construct (HookContainer $container)
 
 onResourceLoaderBeforeResponse (Context $context, array &$extraHeaders)
 Add extra HTTP response headers for the given request context.
 
 onResourceLoaderExcludeUserOptions (array &$keysToExclude, Context $context)
 Exclude a user option from the preloaded data for client-side mw.user.options.
 
 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
Context | null$context
Returns
void This hook must not abort, it must return no value

 
 onResourceLoaderGetConfigVars (array &$vars, $skin, Config $config)
 Export static site-wide mw.config variables to JavaScript.Variables that depend on the current page or request state must be added through MediaWiki\Hook\MakeGlobalVariablesScriptHook instead. The skin name is made available to send skin-specific config only when needed.This hook is called from MediaWiki\ResourceLoader\StartUpModule.
Since
1.35
Parameters
array&$vars[ variable name => value ]
string$skin
Config$configsince 1.34
Returns
void This hook must not abort, it must return no value

 
 onResourceLoaderJqueryMsgModuleMagicWords (Context $context, array &$magicWords)
 Add magic words to the mediawiki.jqueryMsg module.
 
 onResourceLoaderModifyEmbeddedSourceUrls (array &$urls)
 Allow modifying source URLs (i.e.
 
 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.
 
 onResourceLoaderSiteModulePages ( $skin, array &$pages)
 Change which wiki pages comprise the site module in given skin.This hook is called from MediaWiki\ResourceLoader\SiteModule.
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

 
 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

 

Detailed Description

Access: internal

Definition at line 13 of file HookRunner.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\ResourceLoader\HookRunner::__construct ( HookContainer $container)

Definition at line 27 of file HookRunner.php.

Member Function Documentation

◆ onResourceLoaderBeforeResponse()

MediaWiki\ResourceLoader\HookRunner::onResourceLoaderBeforeResponse ( Context $context,
array & $extraHeaders )

Add extra HTTP response headers for the given request context.

These headers are sent regardless of status (200 OK, or 304 Not Modified) and content type (CSS, JS, Image, SourceMap).

This hook is called from ResourceLoaderEntryPoint.

Since
1.45
Parameters
Context$context
string[]&$extraHeaders
Returns
void This hook must not abort, it must return no value

Implements MediaWiki\ResourceLoader\Hook\ResourceLoaderBeforeResponseHook.

Definition at line 101 of file HookRunner.php.

◆ onResourceLoaderExcludeUserOptions()

MediaWiki\ResourceLoader\HookRunner::onResourceLoaderExcludeUserOptions ( array & $keysToExclude,
Context $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
Context$context
Returns
void

Implements MediaWiki\ResourceLoader\Hook\ResourceLoaderExcludeUserOptionsHook.

Definition at line 31 of file HookRunner.php.

◆ onResourceLoaderForeignApiModules()

MediaWiki\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
Context | null$context
Returns
void This hook must not abort, it must return no value

Implements MediaWiki\ResourceLoader\Hook\ResourceLoaderForeignApiModulesHook.

Definition at line 40 of file HookRunner.php.

◆ onResourceLoaderGetConfigVars()

MediaWiki\ResourceLoader\HookRunner::onResourceLoaderGetConfigVars ( array & $vars,
$skin,
Config $config )

Export static site-wide mw.config variables to JavaScript.Variables that depend on the current page or request state must be added through MediaWiki\Hook\MakeGlobalVariablesScriptHook instead. The skin name is made available to send skin-specific config only when needed.This hook is called from MediaWiki\ResourceLoader\StartUpModule.

Since
1.35
Parameters
array&$vars[ variable name => value ]
string$skin
Config$configsince 1.34
Returns
void This hook must not abort, it must return no value

Implements MediaWiki\ResourceLoader\Hook\ResourceLoaderGetConfigVarsHook.

Definition at line 83 of file HookRunner.php.

◆ onResourceLoaderJqueryMsgModuleMagicWords()

MediaWiki\ResourceLoader\HookRunner::onResourceLoaderJqueryMsgModuleMagicWords ( Context $context,
array & $magicWords )

Add magic words to the mediawiki.jqueryMsg module.

The values should be a string, and they may only vary by what's in the Context.

This hook is called from ResourceLoaderJqueryMsgModule.

Since
1.35
Parameters
Context$context
string[]&$magicWordsAssociative array mapping all-caps magic word to a string value
Returns
void This hook must not abort, it must return no value

Implements MediaWiki\ResourceLoader\Hook\ResourceLoaderJqueryMsgModuleMagicWordsHook.

Definition at line 91 of file HookRunner.php.

◆ onResourceLoaderModifyEmbeddedSourceUrls()

MediaWiki\ResourceLoader\HookRunner::onResourceLoaderModifyEmbeddedSourceUrls ( array & $urls)

Allow modifying source URLs (i.e.

URLs to load.php, see ResourceLoader::getSources()) when they are used for output that may be embedded in the page HTML, rather than referenced using <link> etc., and thus the URL will be expanded relative to index.php URLs, rather than other load.php URLs.

The hook must not add or remove sources, and calling the new URL should have a roughly similar outcome to calling the old URL. It is mainly intended to support serving index.php and load.php from different domains.

This hook is currently called from StartUpModule and ImageModule.

Since
1.43
Parameters
string[]&$urlsAn array of source name => URL; the URL might be relative.
Returns
void This hook must not abort, it must return no value

Implements MediaWiki\ResourceLoader\Hook\ResourceLoaderModifyEmbeddedSourceUrlsHook.

Definition at line 48 of file HookRunner.php.

◆ onResourceLoaderRegisterModules()

MediaWiki\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 MediaWiki\ResourceLoader\Hook\ResourceLoaderRegisterModulesHook.

Definition at line 56 of file HookRunner.php.

◆ onResourceLoaderSiteModulePages()

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

Change which wiki pages comprise the site module in given skin.This hook is called from MediaWiki\ResourceLoader\SiteModule.

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 MediaWiki\ResourceLoader\Hook\ResourceLoaderSiteModulePagesHook.

Definition at line 65 of file HookRunner.php.

◆ onResourceLoaderSiteStylesModulePages()

MediaWiki\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 MediaWiki\ResourceLoader\Hook\ResourceLoaderSiteStylesModulePagesHook.

Definition at line 74 of file HookRunner.php.


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