Manual:Hooks/GetContentModels

GetContentModels
Available from version 1.29.0
Allows to add custom content handlers to the list of content models registered with the system.
Define function:
public static function onGetContentModels( &$models ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"GetContentModels": "MediaWiki\\Extension\\MyExtension\\Hooks::onGetContentModels"
	}
}
Called from: File(s): ContentHandler.php
Interface: GetContentModelsHook.php

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


Details

edit
  • &$models: array of content model names. The extension should add its models to this array.

It is recommended that the extensions processing content models via ContentHandlerForModelID hook would register these models using this hook, otherwise the core does not know these models exist.

For more information on content models see ContentHandler.