Manual:Hooks/ParserCloned

From Linux Web Expert

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
ParserCloned
<translate> Available from <tvar name=1><translate> version <tvar (Gerrit change 33506)</tvar></translate>
called when the Parser is cloned
<translate> Define function:</translate>
public static function onParserCloned( $parser ) { ... }
<translate> Attach hook:</translate> <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
	"Hooks": {
		"ParserCloned": "MediaWiki\\Extension\\MyExtension\\Hooks::onParserCloned"
	}
}
<translate> Called from:</translate> <translate> File(s):</translate> Parser.php
<translate> Interface:</translate> ParserClonedHook.php

<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:ParserCloned extensions</tvar>.</translate>


Details

$parser: Newly-cloned Parser object

Purpose

Extensions should use this hook if they store per-instance data in "expando" properties on the Parser object that need to be deep-cloned or cleared for the new Parser object.