Skip to content

Commit 275edbb

Browse files
committed
refactor(registration): Convert to the new HookHandlers interface (closes #58)
1 parent f5735a7 commit 275edbb

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

extension.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
{
22
"name": "Snap! Project Embed",
3-
"version": "2.7.0",
3+
"version": "3.0.0",
44
"author": ["R4356th, GrahamSH, mw-EmbedScratch contributors"],
55
"url": "https://www.mediawiki.org/wiki/Extension:SnapProjectEmbed",
66
"descriptionmsg": "embedsnap-desc",
77
"license-name": "GPLv3",
88
"type": "parserhook",
99
"requires": {
10-
"MediaWiki": ">= 1.25.0"
10+
"MediaWiki": ">=1.35.0"
1111
},
1212
"AutoloadClasses": {
1313
"EmbedSnap": "includes/EmbedSnap.php"
1414
},
15+
"HookHandlers": {
16+
"default": {
17+
"class": "EmbedSnap"
18+
}
19+
},
1520
"Hooks": {
16-
"ParserFirstCallInit": ["EmbedSnap::parserEmbedSnap"]
21+
"ParserFirstCallInit": "default"
1722
},
1823
"MessagesDirs": {
1924
"EmbedSnap": ["i18n"]

includes/EmbedSnap.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,21 @@
1717
Embedding Snap! projects in MediaWiki using <snap> and <snap-project> tags
1818
*/
1919

20+
use MediaWiki\Hook\ParserFirstCallInitHook;
21+
2022
if ( !defined( 'MEDIAWIKI' ) ) {
2123
die( 'Snap! Project Embed requires MediaWiki 1.35 or later to run.' );
2224
}
2325

24-
class EmbedSnap {
26+
class EmbedSnap implements ParserFirstCallInitHook {
2527
/** Register <snap> and <snap-project> tags */
26-
public static function parserEmbedSnap( &$parser ) {
28+
public function onParserFirstCallInit( $parser ) {
2729
$parser->setHook( 'snap', [ __CLASS__,'renderEmbedSnap' ] );
2830
$parser->setHook( 'snap-project', [ __CLASS__,'renderEmbedSnap' ] );
2931
}
3032

3133
/** Function to render the iframes for the <snap> tags */
32-
public static function renderEmbedSnap( $input, $argv, $parser ) {
34+
public function renderEmbedSnap( $input, $argv, $parser ) {
3335
$project = '';
3436
$user = '';
3537
$width = $width_max = 930;

0 commit comments

Comments
 (0)