Manual:Hooks/ApiMakeParserOptions

From MediaWiki.org
Jump to navigation Jump to search
ApiMakeParserOptions
Available from version 1.28.0 (Gerrit change 295256)
allows extensions to adjust the parser options before parsing
Define function:
public static function onApiMakeParserOptions( ParserOptions $options, Title $title, array $params, ApiBase $module, \Wikimedia\ScopedCallback &$reset, bool &$suppressCache ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"ApiMakeParserOptions": "MyExtensionHooks::onApiMakeParserOptions"
	}
}

For MediaWiki ≤1.25:

$wgHooks['ApiMakeParserOptions'][] = 'MyExtensionHooks::onApiMakeParserOptions';
Called from:File(s): api/ApiExpandTemplates.php, api/ApiParse.php
Function(s): execute, makeParserOptions

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:ApiMakeParserOptions extensions.

Details[edit]

  • $options: ParserOptions object
  • $title: Title to be parsed
  • $params: Array of parameters for the API module
  • $module: ApiBase object
  • &$reset: Set to a \Wikimedia\ScopedCallback used to reset any hooks after the parse is done.
  • &$suppressCache: Set true if cache should be suppressed.