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 BadMethodCallException(
'Cannot reset hooks in operation.' );
72 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
73 $hookContainer->clear( $name );
86 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
87 return $hookContainer->isRegistered( $name );
100 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
101 $handlers = $hookContainer->getLegacyHandlers( $name );
102 $funcName =
'on' . strtr( ucfirst( $name ),
':-',
'__' );
103 foreach ( $hookContainer->getHandlers( $name ) as $obj ) {
104 $handlers[] = [ $obj, $funcName ];
131 public static function run( $event, array $args = [], $deprecatedVersion =
null ) {
132 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
133 $options = $deprecatedVersion ? [
'deprecatedVersion' => $deprecatedVersion ] : [];
134 return $hookContainer->run( $event, $args, $options );
148 public static function runWithoutAbort( $event, array $args = [], $deprecatedVersion =
null ) {
149 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
150 $options = $deprecatedVersion ? [
'deprecatedVersion' => $deprecatedVersion ] : [];
151 $options[
'abortable' ] =
false;
152 return $hookContainer->run( $event, $args, $options );
171 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.