diff options
Diffstat (limited to 'GentooPackages/GentooPackages.php')
-rw-r--r-- | GentooPackages/GentooPackages.php | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/GentooPackages/GentooPackages.php b/GentooPackages/GentooPackages.php index 13ab7241..8bd8d576 100644 --- a/GentooPackages/GentooPackages.php +++ b/GentooPackages/GentooPackages.php @@ -1,7 +1,7 @@ <?php -class GentooPackages { - static function packageInfo($input, array $args, Parser $parser, PPFrame $frame) { +class GentooPackages implements MediaWiki\Hook\ParserFirstCallInitHook { + public static function packageInfo($input, array $args, Parser $parser, PPFrame $frame) { $atom = $args['atom']; $type = $args['type']; @@ -21,7 +21,7 @@ class GentooPackages { } } - static function fetchOrError($atom, $type) { + private static function fetchOrError($atom, $type) { global $wgVersion; $url = "https://packages.gentoo.org/packages/${atom}.json"; if ($type !== 'use') { @@ -48,7 +48,7 @@ class GentooPackages { } } - static function render($json) { + private static function render($json) { $use_flags = self::renderFlags($json); $updated_at = strftime('%Y-%m-%d %H:%M', strtotime($json['updated_at'])); $desc = htmlspecialchars($json['description']); @@ -80,7 +80,7 @@ class GentooPackages { HTML; } - static function renderFlags($json) { + private static function renderFlags($json) { $flags = self::sortFlags($json); $html = <<<HTML @@ -110,7 +110,7 @@ HTML; return $html; } - static function sortFlags($json) { + private static function sortFlags($json) { $merged_flags = []; foreach(array_merge($json['use']['global'], $json['use']['local']) as $flag) $merged_flags[$flag['name']] = $flag; @@ -118,10 +118,9 @@ HTML; return $merged_flags; } - static function initHooks($parser) { - global $wgOut; - + public function onParserFirstCallInit($parser) { $parser->setHook('package-info', 'GentooPackages::packageInfo'); - $wgOut->addModules('ext.gentooPackages'); + $output = $parser->getOutput(); + $output->addModules('ext.gentooPackages'); } } |