48 public static function register( $name, $callback ) {
49 if ( !defined(
'MW_SERVICE_BOOTSTRAP_COMPLETE' ) ) {
51 ' before MediaWiki bootstrap complete was deprecated in MediaWiki 1.35',
54 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
55 $hookContainer->register( $name, $callback );
70 public static function clear( $name ) {
72 if ( !defined(
'MW_PHPUNIT_TEST' ) && !defined(
'MW_PARSER_TEST' ) ) {
73 throw new MWException(
'Cannot reset hooks in operation.' );
75 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
76 $hookContainer->clear( $name );
89 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
90 return $hookContainer->isRegistered( $name );
103 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
104 $handlers = $hookContainer->getLegacyHandlers( $name );
105 $funcName =
'on' . strtr( ucfirst( $name ),
':-',
'__' );
106 foreach ( $hookContainer->getHandlers( $name ) as $obj ) {
107 $handlers[] = [ $obj, $funcName ];
134 public static function run( $event, array
$args = [], $deprecatedVersion =
null ) {
135 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
136 $options = $deprecatedVersion ? [
'deprecatedVersion' => $deprecatedVersion ] : [];
137 return $hookContainer->run( $event,
$args, $options );
152 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
153 $options = $deprecatedVersion ? [
'deprecatedVersion' => $deprecatedVersion ] : [];
154 $options[
'abortable' ] =
false;
155 return $hookContainer->run( $event,
$args, $options );
173 return new HookRunner( MediaWikiServices::getInstance()->getHookContainer() );
wfDeprecatedMsg( $msg, $version=false, $component=false, $callerOffset=2)
Log a deprecation warning with arbitrary message text.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
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.