| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Hook; |
| 4 | |
| 5 | use MediaWiki\Parser\Parser; |
| 6 | use MediaWiki\Parser\PPFrame; |
| 7 | |
| 8 | /** |
| 9 | * This is a hook handler interface, see docs/Hooks.md. |
| 10 | * Use the hook name "ParserGetVariableValueSwitch" to register handlers implementing this interface. |
| 11 | * |
| 12 | * @stable to implement |
| 13 | * @ingroup Hooks |
| 14 | */ |
| 15 | interface ParserGetVariableValueSwitchHook { |
| 16 | /** |
| 17 | * This hook is called when the parser needs the value of a |
| 18 | * custom magic word. |
| 19 | * |
| 20 | * @since 1.35 |
| 21 | * |
| 22 | * @param Parser $parser |
| 23 | * @param array &$variableCache Array to cache the value; when you return |
| 24 | * $variableCache[$magicWordId] should be the same as $ret |
| 25 | * @param string $magicWordId Index of the magic word (hook should not mutate it!) |
| 26 | * @param string &$ret Value of the magic word (the hook should set it) |
| 27 | * @param PPFrame $frame PPFrame object to use for expanding any template variables |
| 28 | * @return bool|void True or no return value to continue or false to abort |
| 29 | * @note Setting $variableCache[$magicWordId] is no longer necessary since |
| 30 | * MW 1.39, but hooks may wish to do so for backward compatibility. |
| 31 | */ |
| 32 | public function onParserGetVariableValueSwitch( $parser, &$variableCache, |
| 33 | $magicWordId, &$ret, $frame |
| 34 | ); |
| 35 | } |