Skip to content

Commit

Permalink
Replace deprecated $wgHooks
Browse files Browse the repository at this point in the history
HookContainer service is available since 1.35, just like extension.json
compatibility statement, so no need of a compatibility layer.

Issue: SemanticMediaWiki#781
  • Loading branch information
Seb35 committed Oct 23, 2023
1 parent 0006364 commit f8cfe24
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions SemanticResultFormats.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use MediaWiki\MediaWikiServices;

/**
* @see https://github.com/SemanticMediaWiki/SemanticResultFormats/
*
Expand Down Expand Up @@ -51,31 +53,28 @@ public static function initExtension( $credits = [] ) {
* @since 2.5
*/
public static function registerHooks() {
$formatDir = __DIR__ . '/formats/';


unset( $formatDir );
$hookContainer = MediaWikiServices::getInstance()->getHookContainer();

$GLOBALS['wgHooks']['ParserFirstCallInit'][] = 'SRFParserFunctions::registerFunctions';
$GLOBALS['wgHooks']['UnitTestsList'][] = 'SRFHooks::registerUnitTests';
$hookContainer->register( 'ParserFirstCallInit', 'SRFParserFunctions::registerFunctions' );
$hookContainer->register( 'UnitTestsList', 'SRFHooks::registerUnitTests' );

$GLOBALS['wgHooks']['ResourceLoaderGetConfigVars'][] = 'SRFHooks::onResourceLoaderGetConfigVars';
$hookContainer->register( 'ResourceLoaderGetConfigVars', 'SRFHooks::onResourceLoaderGetConfigVars' );

// Format hooks
$GLOBALS['wgHooks']['OutputPageParserOutput'][] = 'SRF\Filtered\Hooks::onOutputPageParserOutput';
$GLOBALS['wgHooks']['MakeGlobalVariablesScript'][] = 'SRF\Filtered\Hooks::onMakeGlobalVariablesScript';
$hookContainer->register( 'OutputPageParserOutput', 'SRF\Filtered\Hooks::onOutputPageParserOutput' );
$hookContainer->register( 'MakeGlobalVariablesScript', 'SRF\Filtered\Hooks::onMakeGlobalVariablesScript' );

$GLOBALS['wgHooks']['SMW::Store::BeforeQueryResultLookupComplete'][] = 'SRF\DataTables\Hooks::onSMWStoreBeforeQueryResultLookupComplete';
$hookContainer->register( 'SMW::Store::BeforeQueryResultLookupComplete', 'SRF\DataTables\Hooks::onSMWStoreBeforeQueryResultLookupComplete' );

// register API modules
$GLOBALS['wgAPIModules']['ext.srf.slideshow.show'] = 'SRFSlideShowApi';
$GLOBALS['wgAPIModules']['ext.srf.datatables.api'] = 'SRF\DataTables\Api';

// User preference
$GLOBALS['wgHooks']['SMW::GetPreferences'][] = 'SRFHooks::onGetPreferences';
$hookContainer->register( 'SMW::GetPreferences', 'SRFHooks::onGetPreferences' );

// Allows last minute changes to the output page, e.g. adding of CSS or JavaScript by extensions
$GLOBALS['wgHooks']['BeforePageDisplay'][] = 'SRFHooks::onBeforePageDisplay';
$hookContainer->register( 'BeforePageDisplay', 'SRFHooks::onBeforePageDisplay' );
}

/**
Expand All @@ -94,11 +93,12 @@ public static function onExtensionFunction() {
);
}
}
$hookContainer = MediaWikiServices::getInstance()->getHookContainer();

// Admin Links hook needs to be called in a delayed way so that it
// will always be called after SMW's Admin Links addition; as of
// SMW 1.9, SMW delays calling all its hook functions.
$GLOBALS['wgHooks']['AdminLinks'][] = 'SRFHooks::addToAdminLinks';
$hookContainer->register( 'AdminLinks', 'SRFHooks::addToAdminLinks' );

$GLOBALS['srfgScriptPath'] = ( $GLOBALS['wgExtensionAssetsPath'] === false ? $GLOBALS['wgScriptPath'] . '/extensions' : $GLOBALS['wgExtensionAssetsPath'] ) . '/SemanticResultFormats';

Expand Down

0 comments on commit f8cfe24

Please sign in to comment.