Manual:Hooks/ConvertContent
Appearance
From mediawiki.org
| ConvertContent | |
|---|---|
| Available from version 1.21.0 (Gerrit change 32053) Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. | |
| Define function: | public static function onConvertContent( $content, $toModel, $lossy, &$result ) { ... } |
| Attach hook: | In extension.json:
{ "Hooks":{ "ConvertContent":"MediaWiki\\Extension\\MyExtension\\Hooks::onConvertContent" } } |
| Called from: | File(s): AbstractContent.php |
| Interface: | ConvertContentHook.php |
For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:ConvertContent extensions.
Details
[edit ]- $content
- The Content to be converted.
- $toModel
- The ID of the content model to convert to.
- $lossy
- boolean indicating whether lossy conversion is allowed.
- &$result
- Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel.