mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-23 23:33:54 +00:00
Hook: Create HookRunner and interface for own hook
Bug: T348040 Change-Id: I63a7e71a06729dbf607ef9bb275896e42db1b6e0
This commit is contained in:
parent
732069f7fc
commit
3452647071
|
@ -11,6 +11,7 @@ use MediaWiki\ResourceLoader as RL;
|
|||
use MediaWiki\ResourceLoader\Hook\ResourceLoaderSiteModulePagesHook;
|
||||
use MediaWiki\ResourceLoader\Hook\ResourceLoaderSiteStylesModulePagesHook;
|
||||
use MediaWiki\Skins\Hook\SkinPageReadyConfigHook;
|
||||
use MediaWiki\Skins\Vector\Hooks\HookRunner;
|
||||
use OutputPage;
|
||||
use RuntimeException;
|
||||
use SkinTemplate;
|
||||
|
@ -101,10 +102,8 @@ class Hooks implements
|
|||
VectorServices::getLanguageService()->canWordsBeSplitSafely( $context->getLanguage() )
|
||||
];
|
||||
|
||||
MediaWikiServices::getInstance()->getHookContainer()->run(
|
||||
'VectorSearchResourceLoaderConfig',
|
||||
[ &$vectorSearchConfig ]
|
||||
);
|
||||
$hookRunner = new HookRunner( MediaWikiServices::getInstance()->getHookContainer() );
|
||||
$hookRunner->onVectorSearchResourceLoaderConfig( $vectorSearchConfig );
|
||||
|
||||
return array_merge( $config->get( 'VectorWvuiSearchOptions' ), $vectorSearchConfig );
|
||||
}
|
||||
|
|
26
includes/Hooks/HookRunner.php
Normal file
26
includes/Hooks/HookRunner.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Skins\Vector\Hooks;
|
||||
|
||||
use MediaWiki\HookContainer\HookContainer;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class HookRunner implements VectorSearchResourceLoaderConfigHook {
|
||||
private HookContainer $hookContainer;
|
||||
|
||||
public function __construct( HookContainer $hookContainer ) {
|
||||
$this->hookContainer = $hookContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function onVectorSearchResourceLoaderConfig( array &$vectorSearchConfig ): void {
|
||||
$this->hookContainer->run(
|
||||
'VectorSearchResourceLoaderConfig',
|
||||
[ &$vectorSearchConfig ]
|
||||
);
|
||||
}
|
||||
}
|
18
includes/Hooks/VectorSearchResourceLoaderConfigHook.php
Normal file
18
includes/Hooks/VectorSearchResourceLoaderConfigHook.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Skins\Vector\Hooks;
|
||||
|
||||
/**
|
||||
* Use the hook name "VectorSearchResourceLoaderConfig" to register
|
||||
* handlers implementing this interface to modify Vector's search config.
|
||||
*
|
||||
* @stable to implement
|
||||
* @ingroup Hooks
|
||||
*/
|
||||
interface VectorSearchResourceLoaderConfigHook {
|
||||
/**
|
||||
* @param array &$vectorSearchConfig
|
||||
* @return void
|
||||
*/
|
||||
public function onVectorSearchResourceLoaderConfig( array &$vectorSearchConfig ): void;
|
||||
}
|
Loading…
Reference in a new issue