49 public static function register(
$name, $callback ) {
50 self::$handlers[
$name][] = $callback;
63 public static function clear( $name ) {
64 if ( !defined(
'MW_PHPUNIT_TEST' ) && !defined(
'MW_PARSER_TEST' ) ) {
65 throw new MWException(
'Cannot reset hooks in operation.' );
68 unset( self::$handlers[$name] );
82 return !empty(
$wgHooks[$name] ) || !empty( self::$handlers[$name] );
97 if ( !self::isRegistered( $name ) ) {
102 return self::$handlers[
$name];
141 if ( $hook[0] instanceof Closure ) {
142 $fname =
"hook-$event-closure";
149 if ( $method ===
null ) {
150 $method =
"on$event";
154 $callback = [ $object, $method ];
158 throw new MWException(
'Unknown datatype in hooks for ' . $event .
"\n" );
164 throw new MWException(
'Invalid callback ' .
$fname .
' in hooks for ' . $event .
"\n" );
168 if ( $deprecatedVersion !==
null ) {
169 wfDeprecated(
"$event hook (used in $fname)", $deprecatedVersion );
200 public static function run( $event,
array $args = [], $deprecatedVersion =
null ) {
201 foreach ( self::getHandlers( $event ) as $hook ) {
202 $retval = self::callHook( $event, $hook,
$args, $deprecatedVersion );
203 if ( $retval ===
null ) {
211 }
elseif ( $retval ===
false ) {
232 foreach ( self::getHandlers( $event ) as $hook ) {
234 $retval = self::callHook( $event, $hook,
$args, $deprecatedVersion,
$fname );
235 if ( $retval !==
null && $retval !==
true ) {
236 throw new UnexpectedValueException(
"Invalid return from $fname for unabortable $event." );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Exception class which takes an HTML error message, and does not produce a backtrace.
static $handlers
Array of events mapped to an array of callbacks to be run when that event is triggered.
static clear( $name)
Clears hooks registered via Hooks::register().
static callHook( $event, $hook, array $args, $deprecatedVersion=null, &$fname=null)
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.
$wgHooks['ArticleShow'][]
Allows to change the fields on the form that will be generated $name
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))