Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 7 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Hooks | |
0.00% |
0 / 7 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| onParserFirstCallInit | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| onOutputPageParserOutput | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Graph extension Hooks |
| 4 | * |
| 5 | * @file |
| 6 | * @ingroup Extensions |
| 7 | */ |
| 8 | |
| 9 | namespace Graph; |
| 10 | |
| 11 | use MediaWiki\Hook\ParserFirstCallInitHook; |
| 12 | use MediaWiki\Output\Hook\OutputPageParserOutputHook; |
| 13 | use MediaWiki\Output\OutputPage; |
| 14 | use MediaWiki\Parser\Parser; |
| 15 | use MediaWiki\Parser\ParserOutput; |
| 16 | |
| 17 | class Hooks implements |
| 18 | ParserFirstCallInitHook, |
| 19 | OutputPageParserOutputHook |
| 20 | { |
| 21 | |
| 22 | /** |
| 23 | * ParserFirstCallInit hook handler. |
| 24 | * Registers the <graph> tag |
| 25 | * |
| 26 | * @param Parser $parser |
| 27 | */ |
| 28 | public function onParserFirstCallInit( $parser ) { |
| 29 | $parser->setHook( 'graph', [ ParserTag::class, 'onGraphTag' ] ); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * OutputPageParserOutput hook handler |
| 34 | * @param OutputPage $outputPage |
| 35 | * @param ParserOutput $parserOutput ParserOutput instance being added in $outputPage |
| 36 | */ |
| 37 | public function onOutputPageParserOutput( |
| 38 | $outputPage, $parserOutput |
| 39 | ): void { |
| 40 | $config = $outputPage->getContext()->getConfig(); |
| 41 | |
| 42 | // Add whether to use 'save' or 'publish' messages to JavaScript for post-edit, other |
| 43 | // editors, etc. |
| 44 | $outputPage->addJsConfigVars( |
| 45 | 'wgGraphShowInToolbar', |
| 46 | $config->get( 'GraphShowInToolbar' ) |
| 47 | ); |
| 48 | |
| 49 | ParserTag::finalizeParserOutput( $outputPage, $parserOutput ); |
| 50 | } |
| 51 | } |