Open main menu

Manual:Hooks/ContentHandlerForModelID

< Manual:Hooks
ContentHandlerForModelID
Available from version 1.21.0
Allows to provide custom content handlers for content models
Define function:
public static function onContentHandlerForModelID( $modeName, &$handler ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"ContentHandlerForModelID": "MyExtensionHooks::onContentHandlerForModelID"
	}
}

For MediaWiki ≤1.25:

$wgHooks['ContentHandlerForModelID'][] = 'MyExtensionHooks::onContentHandlerForModelID';
Called from:File(s): ContentHandler.php

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

DetailsEdit

  • $modeName: the requested content model name
  • &$handler: set this to a ContentHandler object, if desired.

Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. It is recommended that the extensions processing content models via this hook would register these models using GetContentModels hook, otherwise the core does not know these models exist.

For more information on content models see ContentHandler.