Manual:Hooks/ContentHandlerForModelID

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": "MediaWiki\\Extension\\MyExtension\\Hooks::onContentHandlerForModelID"
	}
}
Called from: File(s): ContentHandler.php
Interface: ContentHandlerForModelIDHook.php

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


Details edit

  • $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.