mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TextExtracts
synced 2024-11-27 09:30:09 +00:00
Use HookHandlers for core hooks
The use of "HookHandlers" attribute in extension.json makes it possible to inject services into hook handler classes in a future patch. Bug: T271032 Change-Id: I612c09264b830fe5588aafdad80a9eebaa66d71b
This commit is contained in:
parent
87dc3cb2db
commit
ce0bcb5c82
|
@ -34,9 +34,12 @@
|
|||
"TextExtracts\\": "includes/"
|
||||
},
|
||||
"Hooks": {
|
||||
"ApiOpenSearchSuggest": [
|
||||
"TextExtracts\\Hooks::onApiOpenSearchSuggest"
|
||||
]
|
||||
"ApiOpenSearchSuggest": "main"
|
||||
},
|
||||
"HookHandlers": {
|
||||
"main": {
|
||||
"class": "TextExtracts\\Hooks"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"ExtractsRemoveClasses": {
|
||||
|
|
|
@ -5,19 +5,20 @@ namespace TextExtracts;
|
|||
use ApiBase;
|
||||
use ApiMain;
|
||||
use ApiResult;
|
||||
use MediaWiki\Api\Hook\ApiOpenSearchSuggestHook;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Request\FauxRequest;
|
||||
|
||||
/**
|
||||
* @license GPL-2.0-or-later
|
||||
*/
|
||||
class Hooks {
|
||||
class Hooks implements ApiOpenSearchSuggestHook {
|
||||
|
||||
/**
|
||||
* ApiOpenSearchSuggest hook handler
|
||||
* @param array &$results Array of search results
|
||||
*/
|
||||
public static function onApiOpenSearchSuggest( &$results ) {
|
||||
public function onApiOpenSearchSuggest( &$results ) {
|
||||
$config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'textextracts' );
|
||||
if ( !$config->get( 'ExtractsExtendOpenSearchXml' ) || $results === [] ) {
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue