MediaWiki REL1_41
Hooks.php
Go to the documentation of this file.
1<?php
2
29
38class Hooks {
39
50 public static function register( $name, $handler ) {
51 wfDeprecated( __METHOD__, '1.35' );
52 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
53 $hookContainer->register( $name, $handler );
54 }
55
67 public static function clear( $name ) {
68 wfDeprecated( __METHOD__, '1.35' );
69 if ( !defined( 'MW_PHPUNIT_TEST' ) && !defined( 'MW_PARSER_TEST' ) ) {
70 throw new LogicException( 'Cannot reset hooks in operation.' );
71 }
72 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
73 $hookContainer->clear( $name );
74 }
75
85 public static function isRegistered( $name ) {
86 wfDeprecated( __METHOD__, '1.35' );
87 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
88 return $hookContainer->isRegistered( $name );
89 }
90
100 public static function getHandlers( $name ) {
101 wfDeprecated( __METHOD__, '1.35' );
102 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
103 return $hookContainer->getHandlerCallbacks( $name );
104 }
105
128 public static function run( $event, array $args = [], $deprecatedVersion = null ) {
129 wfDeprecated( __METHOD__, '1.35' );
130 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
131 $options = $deprecatedVersion ? [ 'deprecatedVersion' => $deprecatedVersion ] : [];
132 return $hookContainer->run( $event, $args, $options );
133 }
134
146 public static function runWithoutAbort( $event, array $args = [], $deprecatedVersion = null ) {
147 wfDeprecated( __METHOD__, '1.35' );
148 $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
149 $options = $deprecatedVersion ? [ 'deprecatedVersion' => $deprecatedVersion ] : [];
150 $options[ 'abortable' ] = false;
151 return $hookContainer->run( $event, $args, $options );
152 }
153
170 public static function runner() {
171 wfDeprecated( __METHOD__, '1.41' );
172 return new HookRunner( MediaWikiServices::getInstance()->getHookContainer() );
173 }
174}
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
Hooks class.
Definition Hooks.php:38
static clear( $name)
Clears hooks registered via Hooks::register().
Definition Hooks.php:67
static runner()
Get a HookRunner instance for calling hooks using the new interfaces.
Definition Hooks.php:170
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition Hooks.php:128
static getHandlers( $name)
Returns an array of all the event functions attached to a hook This combines functions registered via...
Definition Hooks.php:100
static isRegistered( $name)
Returns true if a hook has a function registered to it.
Definition Hooks.php:85
static runWithoutAbort( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition Hooks.php:146
This class provides an implementation of the core hook interfaces, forwarding hook calls to HookConta...
Service locator for MediaWiki core services.