50 public static function register( $name, $handler ) {
52 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
53 $hookContainer->register( $name, $handler );
67 public static function clear( $name ) {
69 if ( !defined(
'MW_PHPUNIT_TEST' ) && !defined(
'MW_PARSER_TEST' ) ) {
70 throw new LogicException(
'Cannot reset hooks in operation.' );
72 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
73 $hookContainer->clear( $name );
87 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
88 return $hookContainer->isRegistered( $name );
102 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
103 return $hookContainer->getHandlerCallbacks( $name );
128 public static function run( $event, array $args = [], $deprecatedVersion =
null ) {
130 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
131 $options = $deprecatedVersion ? [
'deprecatedVersion' => $deprecatedVersion ] : [];
132 return $hookContainer->run( $event, $args, $options );
146 public static function runWithoutAbort( $event, array $args = [], $deprecatedVersion =
null ) {
148 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
149 $options = $deprecatedVersion ? [
'deprecatedVersion' => $deprecatedVersion ] : [];
150 $options[
'abortable' ] =
false;
151 return $hookContainer->run( $event, $args, $options );
172 return new HookRunner( MediaWikiServices::getInstance()->getHookContainer() );
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
static clear( $name)
Clears hooks registered via Hooks::register().
static runner()
Get a HookRunner instance for calling hooks using the new interfaces.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
static getHandlers( $name)
Returns an array of all the event functions attached to a hook This combines functions registered via...
static isRegistered( $name)
Returns true if a hook has a function registered to it.
static runWithoutAbort( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.